簡體   English   中英

Spring Boot應用程序將無法在Tomcat服務器上啟動

[英]Spring boot app won't start on Tomcat Server

我正在嘗試將Spring Boot應用程序作為WAR部署到tomcat服務器。 我可以將戰爭建立並部署到tomcat服務器。 當我啟動服務器時,盡管我的spring應用程序從未運行。 服務器啟動正常。 我已經完成了Spring所說的在這里所做的一切,

http://docs.spring.io/spring-boot/docs/current/reference/htmlsingle/#howto-create-a-deployable-war-file

我的項目有自己的自定義父POM,由2個模塊組成。

我已經閱讀了其他幾個類似的主題,據我所知,我已經正確設置了所有內容,但顯然出了點問題。 任何幫助將非常感激。

謝謝!

父pom

<groupId>com.project</groupId>
<artifactId>TelematicsNotificationSystem</artifactId>
<name>TelematicsNotificationSystem</name>
<version>1.0.0-SNAPSHOT</version>
<packaging>pom</packaging>

<properties>
    <java.version>1.8</java.version>
    <artifact-deployer.version>2.0.0-RELEASE</artifact-deployer.version>
    <cxf.version>2.5.2</cxf.version>
    <start-class>com.project.TNS.TelematicsNotificationSystem</start-class>
</properties>

<modules>
    <module>TelematicsNotificationSystem-wsclient</module>
    <module>TelematicsNotificationSystem-web</module>
</modules>

<dependencies>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-thymeleaf</artifactId>
        <version>1.5.0.RELEASE</version>
    </dependency>

    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-web</artifactId>
        <version>1.5.0.RELEASE</version>
    </dependency>

    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-tomcat</artifactId>
        <scope>provided</scope>
        <version>1.5.0.RELEASE</version>
    </dependency>

    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-devtools</artifactId>
        <optional>true</optional>
        <version>1.5.0.RELEASE</version>
    </dependency>

    <dependency>
        <groupId>com.sun.mail</groupId>
        <artifactId>javax.mail</artifactId>
        <version>1.5.6</version>
    </dependency>

    <dependency>
        <groupId>org.springframework.ldap</groupId>
        <artifactId>spring-ldap-core</artifactId>
        <version>1.3.0.RELEASE</version>
    </dependency>       
</dependencies>

Web項目Pom

<artifactId>TelematicsNotificationSystem-Web</artifactId>
<name>TelematicsNotificationSystem-Web</name>
<packaging>war</packaging>


<parent>
    <groupId>com.project</groupId>
    <artifactId>TelematicsNotificationSystem</artifactId>
    <version>1.0.0-SNAPSHOT</version>
</parent>

<properties>
    <start-class>com.project.TNS.TelematicsNotificationSystem</start-class>
</properties>



<build>
    <plugins>
        <plugin>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-maven-plugin</artifactId>
            <configuration>
                <resources>
                <resource>
                    <filtering>true</filtering>
                    <directory>src/main/resources/</directory>
                </resource>
                </resources>
            </configuration>
        </plugin>
    </plugins>
</build>

我的申請類別

package TNS;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.boot.context.web.SpringBootServletInitializer;

@SpringBootApplication
public class TelematicsNotificationSystem extends SpringBootServletInitializer{

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

@Override
protected SpringApplicationBuilder configure(SpringApplicationBuilder application) {
    return application.sources(TelematicsNotificationSystem.class);
}

}

一旦部署在Tomcat中,請記住刷新應用程序。 它可能運行良好,只需要刷新即可。

盡管我同意Deinum的觀點,但我需要清理Pom,但這並不是整體解決方案。 解決的方法是簡單地將一個組件掃描添加到包含我的主要方法的類中。

@SpringBootApplication
@ComponentScan(basePackageClasses = DashBoardController.class)
public class TelematicsNotificationSystem extends SpringBootServletInitializer

起始應用程序找不到控制器,因此它可以處理我的任何映射請求。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM