Java IntelliJ进程在spring引导运行时结束,退出代码为0
从IntelliJ Idea启动spring boot应用程序时出现问题。当通过终端运行应用程序时,我没有这个问题Java IntelliJ进程在spring引导运行时结束,退出代码为0,java,spring,intellij-idea,spring-boot,Java,Spring,Intellij Idea,Spring Boot,从IntelliJ Idea启动spring boot应用程序时出现问题。当通过终端运行应用程序时,我没有这个问题 :: Spring Boot :: (v1.2.1.RELEASE) 2015-09-24 12:22:44.274 WARN 22380 --- [ main] n.sf.ehcache.config.CacheConfiguration : Cache 'publicationsCount' is set to eternal but
:: Spring Boot :: (v1.2.1.RELEASE)
2015-09-24 12:22:44.274 WARN 22380 --- [ main] n.sf.ehcache.config.CacheConfiguration : Cache 'publicationsCount' is set to eternal but also has TTI/TTL set. To avoid this warning, clean up the config removing conflicting values of eternal, TTI and TTL. Effective configuration for Cache 'publicationsCount' will be eternal='true', timeToIdleSeconds='0', timeToLiveSeconds='0'.
Process finished with exit code 0
我认为这不是原因。原因可能是什么?删除提供的spring boot starter tomcat依赖项范围对我有帮助
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-tomcat</artifactId>
</dependency>
org.springframework.boot
弹簧启动机tomcat
在pom.xml中添加以下依赖项:
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-tomcat</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
<scope>test</scope>
</dependency>
org.springframework.boot
弹簧靴起动器
org.springframework.boot
弹簧起动试验
测试
org.springframework.boot
弹簧启动机tomcat
org.springframework.boot
SpringBootStarterWeb
测试
我从(sprint Initializer)创建了一个简单的项目,并添加了一个简单的控制器来运行应用程序
@RestController
public class testController {
@GetMapping(value="/")
//@RequestMapping(value="/",method=RequestMethod.GET)
public String hello(){
return "Hello World!!";
}
}
但它没有开始,因为我的pom没有
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
以下是我的pom依赖项:
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</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-security</artifactId>
</dependency>
<dependency>
<groupId>org.apache.kafka</groupId>
<artifactId>kafka-streams</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.kafka</groupId>
<artifactId>spring-kafka</artifactId>
</dependency>
<dependency>
<groupId>com.h2database</groupId>
<artifactId>h2</artifactId>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.postgresql</groupId>
<artifactId>postgresql</artifactId>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
<exclusions>
<exclusion>
<groupId>org.junit.vintage</groupId>
<artifactId>junit-vintage-engine</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.springframework.kafka</groupId>
<artifactId>spring-kafka-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework.security</groupId>
<artifactId>spring-security-test</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
org.springframework.boot
spring引导启动器数据jpa
org.springframework.boot
SpringBootStarterWeb
org.springframework.boot
弹簧启动安全
org.apache.kafka
卡夫卡河
org.springframework.kafka
春天卡夫卡
com.h2数据库
氢
运行时
org.postgresql
postgresql
运行时
org.springframework.boot
弹簧起动试验
测试
org.junit.vintage
朱尼特老式发动机
org.springframework.kafka
弹簧卡夫卡试验
测试
org.springframework.security
弹簧安全性试验
测试
注意:您可能不需要上述所有依赖项。在我的例子中,我是作为 管理员 ,那么它就起作用了 确保您具有tomcat依赖性
<dependency>
<groupId>org.apache.tomcat.embed</groupId>
<artifactId>tomcat-embed-core</artifactId>
<version>9.0.29</version>
</dependency>
org.apache.tomcat.embed
tomcat嵌入式内核
9.0.29
在我的例子中,以下两者之间有一点不同:
- 只需在IntelliJ最可见的底部单击Run,然后
- 在src/main/java/com.exampler.your应用程序中查找默认控制器,右键单击并按Run
第二个选项就是正确运行项目。添加spring boot starter web解决了我的问题
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
org.springframework.boot
SpringBootStarterWeb
退出代码0表示应用程序结束时没有出现错误。那么问题出在哪里?但它不应该关闭。Spring boot应该等待运行,等待请求。只有在应用程序中包含了web服务器时才可以,而您没有指定。因此,如果您需要更多帮助,您应该发布相关配置。愚蠢的原因可能是SpringApplication.run()
中存在错误的类。谢谢,我删除了我的gradle等效项:providedRuntime'org.springframework.boot:spring boot starter tomcat'
这很有效。但是你能告诉我为什么这样做有效吗。是因为“提供”意味着它只在编译期间可用吗?添加spring boot starter web依赖项解决了我的问题
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>