2016-04-14 57 views
0

我在部署tomcat應用程序時遇到了一些問題。事情是當我從孩子項目部署應用程序,然後它工作正常,而如果我從父項目運行應用程序,它不會正確加載應用程序 。我看到了tomcat的控制檯上有些例外像 Tomcat是綁定等春季啓動 - 父母和孩子有不同的主要方法

我的問題 - 這是可能的,這兩個應用程序(父母和孩子)的應用程序有它自己的Application.Java類,因爲孩子的項目添加爲父母的依賴項目?

如果我殺的java程序然後只加載父應用程序而不是應用程序,當我停止Tomcat服務器,並再次運行相同的Tomcat端口例外再來。

父項目 Example.Java

@RequestMapping("/test/**") 
@RestController 
public class Example { 

    @RequestMapping(method = RequestMethod.GET, produces = {MediaType.APPLICATION_JSON_VALUE}) 
    public String index() { 
     return "Hello World"; 
    } 

HelloWorldApplication.java

@Configuration 
    @ComponentScan 
    @EnableAutoConfiguration 
    public class HelloWorldApplication { 

     public static void main(String[] args) { 
      SpringApplication.run(HelloWorldApplication.class, args); 
     } 

的pom.xml

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> 
    <modelVersion>4.0.0</modelVersion> 
    <groupId>dashboard</groupId> 
    <artifactId>com.pos.interfaces</artifactId> 
    <version>0.0.1-SNAPSHOT</version> 
    <packaging>jar</packaging> 
     <parent> 
     <groupId>org.springframework.boot</groupId> 
     <artifactId>spring-boot-starter-parent</artifactId> 
     <version>1.2.1.RELEASE</version> 
    </parent> 

<properties> 
    <!-- The main class to start by executing java -jar --> 
    <start-class>com.pos.dashboard.backend.HelloWorldApplication</start-class> 
    </properties> 

<dependencies> 
    <dependency> 
      <groupId>org.springframework.boot</groupId> 
      <artifactId>spring-boot-starter-web</artifactId> 
     </dependency> 
     <dependency> 
      <groupId>org.springframework.boot</groupId> 
      <artifactId>spring-boot-starter-tomcat</artifactId> 
      <scope>provided</scope> 
     </dependency> 

     <dependency> 
      <groupId>jira-widget-app</groupId> 
      <artifactId>spring-boot-starter-tomcat</artifactId> 
      <scope>provided</scope> 
     </dependency> 
    <dependency> 
     <groupId>dashboard</groupId> 
     <artifactId>jira-widget-app</artifactId> 
     <version>0.0.1-SNAPSHOT</version> 
    </dependency> 
    </dependencies> 

    <build> 
     <plugins> 
      <plugin> 
       <groupId>org.springframework.boot</groupId> 
       <artifactId>spring-boot-maven-plugin</artifactId> 
      </plugin> 

      <plugin> 
       <groupId>org.springframework.boot</groupId> 
       <artifactId>spring-boot-maven-plugin</artifactId> 
       <executions> 
        <execution> 
         <goals> 
          <goal>repackage</goal> 
         </goals> 
        </execution> 
       </executions> 
      </plugin> 
    </plugins> 
    </build> 
</project> 

子項目 Example.java

package com.jira.pos.widget; 
@RequestMapping("/tester/**") 
@RestController 
public class Example { 

    @RequestMapping(method = RequestMethod.GET, produces = {MediaType.APPLICATION_JSON_VALUE}) 
    public String index() { 
     return "Hello World"; 
    } 

HelloWorldApplication1的.java

package com.jira.pos.widget; 
    @Configuration 
    @ComponentScan 
    @EnableAutoConfiguration 
    public class HelloWorldApplication1 { 

     public static void main(String[] args) { 
      SpringApplication.run(HelloWorldApplication1.class, args); 
     } 

的pom.xml

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> 
    <modelVersion>4.0.0</modelVersion> 
    <parent> 
    <groupId>dashboard</groupId> 
    <artifactId>com.pos.interfaces</artifactId> 
    <version>0.0.1-SNAPSHOT</version> 
    </parent> 
    <packaging>jar</packaging> 

    <properties> 
    <!-- The main class to start by executing java -jar --> 
    <start-class>com.jira.pos.widget.HelloWorldApplication1</start-class> 
    </properties> 
</project>  

此外,兩個項目都有自己的服務,jsps和主要方法等任何想法我怎麼能擺脫這個問題?

回答

0

這是不容易從你的問題正是明白這個問題,但我「認爲」這兩個應用程序正在使用Tomcat,然後試圖啓動他們登記和,因爲他們倆都開始使用默認的端口,這是8080 ,這可能是你獲取端口綁定異常的原因。

你有沒有試過在src /主/資源/兩個父母和孩子的application.properties財產server.port設置爲兩個不同的值,例如父母8282和孩子8585,看看問題是否依然存在?