Spring Boot应用程序在启动后立即关闭

Env*_*yIT 6 windows spring spring-mvc intellij-idea spring-boot

我目前正在开发一个包含Spring Framework的项目.一切都在起作用,但有一个问题.当我尝试将我的应用程序启动到我的笔记本电脑上时,它会在启动后立即关闭.它正在处理其他所有机器,所以这个问题只出现在我的笔记本电脑上.

也许你知道什么可以迫使这个问题?我正在使用IntelliJ,我还没有找到解决这个问题的方法. PC规格

  • 笔记本电脑是华硕N550JK(改装RAM和SSD)
  • 英特尔酷睿i7-4700HQ CPU@2.4 GHz
  • 16 GB Ram
  • 500 GB SSD三星EVO 840
  • 1 TB硬盘
  • 64位操作系统 - Windows 10

ConsoleOutput

Exclusions:
-----------

    None


Unconditional classes:
----------------------

    org.springframework.boot.autoconfigure.web.WebClientAutoConfiguration

    org.springframework.boot.autoconfigure.context.PropertyPlaceholderAutoConfiguration

    org.springframework.boot.autoconfigure.context.ConfigurationPropertiesAutoConfiguration

    org.springframework.boot.autoconfigure.info.ProjectInfoAutoConfiguration



2017-04-22 21:24:15.756  INFO 6300 --- [           main] com.objectbay.test.me.Application        : Started Application in 8.012 seconds (JVM running for 9.251)
2017-04-22 21:24:15.758  INFO 6300 --- [       Thread-3] s.c.a.AnnotationConfigApplicationContext : Closing org.springframework.context.annotation.AnnotationConfigApplicationContext@6fb0d3ed: startup date [Sat Apr 22 21:24:08 CEST 2017]; root of context hierarchy
2017-04-22 21:24:15.763  INFO 6300 --- [       Thread-3] o.s.j.e.a.AnnotationMBeanExporter        : Unregistering JMX-exposed beans on shutdown
2017-04-22 21:24:15.764  INFO 6300 --- [       Thread-3] j.LocalContainerEntityManagerFactoryBean : Closing JPA EntityManagerFactory for persistence unit 'default'
2017-04-22 21:24:15.765  INFO 6300 --- [       Thread-3] org.hibernate.tool.hbm2ddl.SchemaExport  : HHH000227: Running hbm2ddl schema export
2017-04-22 21:24:15.771 DEBUG 6300 --- [       Thread-3] org.hibernate.SQL                        : drop table person if exists
2017-04-22 21:24:15.782  INFO 6300 --- [       Thread-3] org.hibernate.tool.hbm2ddl.SchemaExport  : HHH000230: Schema export complete

Process finished with exit code 0
Run Code Online (Sandbox Code Playgroud)

的pom.xml

<?xml version="1.0" encoding="UTF-8"?>
<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>org.springframework</groupId>
    <artifactId>gs-accessing-data-rest</artifactId>
    <version>0.1.0</version>

    <parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>1.5.2.RELEASE</version>
    </parent>

    <properties>
        <java.version>1.8</java.version>
    </properties>

    <dependencies>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-data-rest</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-data-jpa</artifactId>
        </dependency>
        <dependency>
            <groupId>com.h2database</groupId>
            <artifactId>h2</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-test</artifactId>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.hibernate.javax.persistence</groupId>
            <artifactId>hibernate-jpa-2.1-api</artifactId>
            <version>1.0.0.Final</version>
        </dependency>
        <dependency>
            <groupId>org.hibernate.javax.persistence</groupId>
            <artifactId>hibernate-jpa-2.1-api</artifactId>
            <version>1.0.0.Final</version>
        </dependency>
    </dependencies>

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

    <repositories>
        <repository>
            <id>spring-releases</id>
            <url>https://repo.spring.io/libs-release</url>
        </repository>
    </repositories>
    <pluginRepositories>
        <pluginRepository>
            <id>spring-releases</id>
            <url>https://repo.spring.io/libs-release</url>
        </pluginRepository>
    </pluginRepositories>
</project>
Run Code Online (Sandbox Code Playgroud)

在我的机器上没有工作的完整示例 Spring Guide Rest示例

控制台 - 更新依赖项后更新依赖项 LOG后的LOG

Env*_*yIT 9

问题解决了 - 感谢您的帮助crazycoder.该问题是由较旧版本的tomcat引起的.在将Spring的嵌入式tomcat升级到1.5.3_RELEASE并更新mysql-jdbc-driver之后,它终于为我工作了.我像这样调整了pom.xml:

<parent>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-parent</artifactId>
    <version>2.0.0.RELEASE</version>
</parent>
Run Code Online (Sandbox Code Playgroud)

  • 如果不是上述问题,有时会在 jar 损坏时发生。通常我运行 mvn clean package 并修复它。 (2认同)

cod*_*kix 9

对我来说,造成这种情况的原因是我在下面的应用程序属性中有这个属性(错误地从测试 application.properties 文件中携带)。查看包含的任何属性文件是否如下所示,然后将其删除:

# disables the servlet-container initialization (for unit testing only)
spring.main.web-application-type=none
Run Code Online (Sandbox Code Playgroud)


小智 6

添加此依赖项:

    <dependency>
        <groupId>org.springframework.boot</groupId>
       <artifactId>spring-boot-starter-web</artifactId>
    </dependency>
Run Code Online (Sandbox Code Playgroud)