Springboot应用程序立即退出
当我运行我的Springboot应用程序立即退出,spring,spring-boot,intellij-idea,Spring,Spring Boot,Intellij Idea,当我运行我的spring boot应用程序时,它会立即退出(使用退出代码0),如下所示: \\/ ___)| |_)| | | | | || (_| | ) ) ) ) ' |____| .__|_| |_|_| |_\__, | / / / / =========|_|==============|___/=/_/_/_/ :: Spring Boot :: (v2.1.0.RELEASE) 2018-11-27 14:08:31.219 INFO 94920
spring boot
应用程序时,它会立即退出(使用退出代码0
),如下所示:
\\/ ___)| |_)| | | | | || (_| | ) ) ) )
' |____| .__|_| |_|_| |_\__, | / / / /
=========|_|==============|___/=/_/_/_/
:: Spring Boot :: (v2.1.0.RELEASE)
2018-11-27 14:08:31.219 INFO 94920 --- [ restartedMain] c.springbootsecurity.jwt.JwtApplication : Starting JwtApplication on 1000810002637M.local with PID 94920 (/Users/723305/Documents/spring/springbootSecure/target/classes started by 723305 in /Users/723305/Documents/spring/springbootSecure)
2018-11-27 14:08:31.222 INFO 94920 --- [ restartedMain] c.springbootsecurity.jwt.JwtApplication : No active profile set, falling back to default profiles: default
2018-11-27 14:08:31.252 INFO 94920 --- [ restartedMain] .e.DevToolsPropertyDefaultsPostProcessor : Devtools property defaults active! Set 'spring.devtools.add-properties' to 'false' to disable
2018-11-27 14:08:31.722 INFO 94920 --- [ restartedMain] o.s.b.d.a.OptionalLiveReloadServer : LiveReload server is running on port 35729
2018-11-27 14:08:31.743 INFO 94920 --- [ restartedMain] c.springbootsecurity.jwt.JwtApplication : Started JwtApplication in 0.752 seconds (JVM running for 1.294)
Process finished with exit code 0
我的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>com.springbootSecurity</groupId>
<artifactId>jwt</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>jar</packaging>
<name>jwt</name>
<description>Demo project for Spring Boot</description>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.1.0.RELEASE</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<java.version>1.8</java.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-security</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-devtools</artifactId>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework.security</groupId>
<artifactId>spring-security-test</artifactId>
<scope>test</scope>
</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>
</plugin>
</plugins>
</build>
</project>
4.0.0
com.springbootSecurity
jwt
0.0.1-快照
罐子
jwt
SpringBoot的演示项目
org.springframework.boot
spring启动程序父级
2.1.0.1发布
UTF-8
UTF-8
1.8
org.springframework.boot
弹簧启动安全
org.springframework.boot
弹簧靴开发工具
运行时
org.springframework.boot
弹簧起动试验
测试
org.springframework.security
弹簧安全性试验
测试
org.springframework.boot
springbootmaven插件
org.springframework.boot
springbootmaven插件
我看不出这有什么问题
Process finished with exit code 0
这个过程结束得很愉快
如果您的应用程序没有
springbootstarterweb
依赖关系,那么它就不会启动任何服务器,也不会等待任何请求
它非常类似于一个main方法,它没有任何东西要执行或在主代码完成后立即完成。因为您在pom.xml中使用了spring boot,所以您没有将它声明为starter web项目 立即关闭,这是一种预期行为,现在要作为web容器运行,您需要在pom.xml中添加以下代码
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
org.springframework.boot
SpringBootStarterWeb
我也有同样的问题。像springbootstarterweb
或删除依赖项springbootstartertomcat
这样的依赖项都不起作用。我使用的是IntelliJ Idea社区版。我认为这与IntelliJ Idea社区版本有关,因为他们提到社区版本中不支持spring,只支持最终(商业)版本,至少对mac是这样
我之所以这么想,是因为我切换到了VisualStudio代码,为spring boot安装了必要的插件,并且它是开箱即用的,使用了我现有的pom.xml
文件
我当前的依赖项是:
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-tomcat</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-devtools</artifactId>
<scope>runtime</scope>
<optional>true</optional>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
org.springframework.boot
弹簧启动机tomcat
org.springframework.boot
弹簧靴起动器
org.springframework.boot
SpringBootStarterWeb
org.springframework.boot
弹簧靴开发工具
运行时
真的
org.springframework.boot
弹簧起动试验
测试
可能值得一提的是,在没有
spring boot starter tomcat
依赖项的情况下,它也可以工作。我刚刚遇到了IntelliJ的问题(即使是spring boot starter web
),通过编辑启动器并选中包含“提供”范围的依赖项来解决它
web应用程序在命令行中运行正常。确保运行Maven Build来安装所有依赖项
请添加更多详细信息。您刚刚发布了很多代码和您的pom
,我们不知道情况和您尝试了什么yetSo,我使用spring initialiser创建了一个应用程序并尝试运行它,它显示了上面的消息。google上的大多数帖子都建议删除依赖tomcat的提供者,但我没有。你没有显示main()或任何你自己的bean吗?有你的代码吗?@moilejter没有,我只是用springinitializer创建了应用程序,它甚至没有运行。我只有主课@SpringBootApplication公共类JwtApplication{public static void main(字符串[]args){SpringApplication.run(JwtApplication.class,args);}}}`。我想这会对你有所帮助。org.springframework.boot-springbootstarterweb。即使这样也不行,你还能得到同样的日志吗?有没有像“tomcat在8080端口启动”这样的日志没有出现?很奇怪。似乎没有将web依赖项添加到类路径中。您可以重新导入模块的所有依赖项并重新启动应用程序吗?执行maven clean install将重新导入所有依赖项spring boot starter web
是必需的。您应该添加org.springframework.boot spring boot starter web
,正如我写的:“spring boot starter web事件”;-)我在intellij中也遇到了同样的问题,但是在切换依赖项之后,右键单击project->maven->reload project(如所述)解决了这个问题。我让spring启动了web依赖项,但它仍然处于退出状态。