简体   繁体   English

在外部TOMCAT中启动后,Spring Boot Application立即关闭

[英]Spring Boot Application immediately shuts down after starting in external TOMCAT

Spring boot immediately shuts down after starting in external TOMCAT. 在外部TOMCAT中启动后,Spring Boot立即关闭。 But in Eclipse this runs well and JAR with embed too. 但是在Eclipse中,它运行良好,并且还嵌入了JAR。

I use Tomcat 7 and JAVA 8. I read a lot of webs and documentation which do not exist. 我使用Tomcat 7和JAVA8。我阅读了许多不存在的Web和文档。

My Eclipse POM is: 我的Eclipse POM是:

http://maven.apache.org/xsd/maven-4.0.0.xsd"> 4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd“> 4.0.0

<groupId>com.suez.demo</groupId>
<artifactId>Myapp</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>war</packaging>

<name>Myappname</name>
<description>Demo project for Spring Boot</description>

<parent>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-parent</artifactId>
    <version>1.5.6.RELEASE</version>
    <relativePath/>
</parent>
<properties>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
    <java.version>1.8</java.version>
    <start-class>com.suez.demo.SuezApplication</start-class>
</properties>
<dependencies>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-tomcat</artifactId>
        <scope>provided</scope>
    </dependency>       
    <dependency>
        <groupId>com.google.code.gson</groupId>
        <artifactId>gson</artifactId>
    </dependency>
    <dependency>
        <groupId>javax.mail</groupId>
        <artifactId>mail</artifactId>
        <version>1.4.7</version>
    </dependency>       
    <dependency>
        <groupId>org.json</groupId>
        <artifactId>json</artifactId>
    </dependency>       
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-web</artifactId>
    </dependency>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-web-services</artifactId>
    </dependency>
    <dependency>
        <groupId>mysql</groupId>
        <artifactId>mysql-connector-java</artifactId>
    </dependency>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-data-jpa</artifactId>
      </dependency>
    <dependency>
        <groupId>org.apache.xmlbeans</groupId>
        <artifactId>xmlbeans</artifactId>
         <version>2.3.0</version>
    </dependency>   
    <dependency>
        <groupId>com.notnoop.apns</groupId>
        <artifactId>apns</artifactId>
         <version>1.0.0.Beta6</version>
    </dependency>
 <dependency>
        <groupId>org.springframework.security</groupId>
        <artifactId>spring-security-web</artifactId>
    </dependency>
    <dependency>
        <groupId>org.springframework.security</groupId>
        <artifactId>spring-security-config</artifactId>
    </dependency>
     <dependency>
        <groupId>io.jsonwebtoken</groupId>
        <artifactId>jjwt</artifactId>
         <version>0.7.0</version>
    </dependency>
</dependencies>

<build>
    <plugins>
        <plugin>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-maven-plugin</artifactId>
             <version>2.0.0.RELEASE</version>
        </plugin>           
          <plugin>
            <groupId>org.jvnet.jaxb2.maven2</groupId>
            <artifactId>maven-jaxb2-plugin</artifactId>
            <version>0.13.3</version>
            <executions>
                <execution>
                    <goals>
                        <goal>generate</goal>
                    </goals>
                </execution>
            </executions>
            <configuration>
                <generatePackage>com.suez.demo.ws</generatePackage>
                <generateDirectory>${project.basedir}/src/main/java</generateDirectory>
                <schemaDirectory>${project.basedir}/src/main/resources</schemaDirectory>
                <schemaIncludes>
                    <include>*.wsdl</include>
                </schemaIncludes>
            </configuration>
        </plugin> 

    </plugins>
</build>

Tomcat output log last lines are: Tomcat输出日志的最后几行是:

2018-06-29 10:27:37.874  INFO 640 --- [ost-startStop-3] com.suez.demo.SuezApplication            : Started SuezApplication in 29.104 seconds (JVM running for 91.714)
2018-06-29 10:27:37.905  INFO 640 --- [ost-startStop-3] ationConfigEmbeddedWebApplicationContext : Closing org.springframework.boot.context.embedded.AnnotationConfigEmbeddedWebApplicationContext@75e8c829: startup date [Fri Jun 29 10:27:11 CEST 2018]; root of context hierarchy
2018-06-29 10:27:37.936  INFO 640 --- [ost-startStop-3] o.s.j.e.a.AnnotationMBeanExporter        : Unregistering JMX-exposed beans on shutdown
2018-06-29 10:27:37.952  INFO 640 --- [ost-startStop-3] j.LocalContainerEntityManagerFactoryBean : Closing JPA EntityManagerFactory for persistence unit 'default'

Can someone help me please? 有人能帮助我吗?

It's hard to say out of the information you've provided, but what looks suspicious to me is that you're using spring-boot-starter-web which in turn brings tomcat starter transitively. 很难说出您提供的信息,但是对我来说,可疑的是您使用的是spring-boot-starter-web,这反过来又带来了tomcat启动器。

I see that the packaging of this module is WAR, so its intended to run in an external web container, but on the other hand, you say that it runs fine in "JAR with embed too". 我看到该模块的包装是WAR,因此它打算在外部Web容器中运行,但是另一方面,您说它在“嵌入JAR”中也可以正常运行。 So it's a little bit confusing. 所以这有点令人困惑。

I've never by myself deployed spring boot application as a WAR file, but I believe you can go to Start.spring.io and generate a sample application that will package itself into WAR. 我从来没有一个人将Spring Boot应用程序部署为WAR文件,但是我相信您可以转到Start.spring.io并生成一个示例应用程序,该应用程序会将其自身打包到WAR中。 This option is not shown by default, so you'll have to click on "switch to the full version" link 默认情况下不显示此选项,因此您必须单击“切换到完整版本”链接

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Spring Boot 2.4.3 应用程序启动后立即关闭 - Spring Boot 2.4.3 application immediately shuts down after starting 舵图 spring 启动应用程序启动后立即关闭 - Helm chart spring boot application shut down immediately after starting 当Tomcat关闭时,在Spring Boot中关闭Executor服务 - Shutdown of Executor service in Spring Boot when Tomcat shuts down spring-boot应用程序启动后立即关闭(计划的) - spring-boot application shutdown immediately after starting (schedular) Spring Boot 应用程序未在 Tomcat 上启动 - Spring boot application not starting on Tomcat Spring 引导应用程序在启动后立即关闭 - Spring Boot application shutting down immediately after start Spring Boot Maven插件:spring-boot:start立即关闭Web应用程序(使用码头) - Spring boot maven plugin: spring-boot:start shuts down the web app immediately (using jetty) TextWatcher 启动后关闭我的应用程序 - TextWatcher shuts down my application after starting up Spring Boot 应用程序未在外部 Tomcat 中启动(在 Tomcat 8.5 和 10 中均已尝试) - Spring Boot application is not starting in external Tomcat (tried both in Tomcat 8.5 and 10) Spring 启动应用程序立即关闭 - Spring Boot application shutting down immediately
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM