我正在尝试将在tomcat上运行的现有应用程序更改为SpringBoot。它一直运行到实际的SpringBoot启动。我有一个类似的应用程序在springBoot上运行。这就是我知道它一直运行到springboot。
我的主要方法:
@Configuration
@EnableAutoConfiguration
@ComponentScan
public class Main {
public static void main(String[] args) {
//Every argument passed needs to become a system property
for (String arg : args) {
System.getProperties().setProperty(arg.split("=")[0], arg.split("=")[1]);
}
SpringApplication.run(Main.class, args);
}}
POM.xml有springboot父标记:
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.0.0.M4</version>
</parent>
我有springboot maven插件:
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
属性具有开始标记:
<start-class>com.sample.requesthandler.Main</start-class>
依赖关系有starter-web和starter-acuator:
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
我尝试使用带有basePackages的@componentScan运行main方法,如下所示:
@ComponentScan(basePackages="com.sample.requesthandler")
这没有帮助。 我尝试在主类的顶部添加@SpringBootApplication注释。这也没有用。
以下是完整日志:
15:59:29,832 |-INFO in ch.qos.logback.core.joran.action.AppenderAction - About to instantiate appender of type
[ch.qos.logback.core.ConsoleAppender]
15:59:29,833 |-INFO in ch.qos.logback.core.joran.action.AppenderAction - Naming appender as [STDOUT]
15:59:29,833 |-INFO in
ch.qos.logback.core.joran.action.NestedComplexPropertyIA - Assuming
default type [ch.qos.logback.classic.encoder.PatternLayoutEncoder] for
[encoder] property
15:59:29,834 |-INFO in ch.qos.logback.classic.joran.action.LoggerAction - Setting level of logger [big-sur] to ERROR
15:59:29,834 |-INFO in ch.qos.logback.classic.joran.action.LoggerAction - Setting additivity of logger [big-sur] to false
15:59:29,834 |-INFO in
ch.qos.logback.core.joran.action.AppenderRefAction - Attaching appender
named [FILE] to Logger[big-sur]
15:59:29,835 |-INFO in
ch.qos.logback.core.joran.action.AppenderRefAction - Attaching appender
named [STDOUT] to Logger[big-sur]
15:59:29,835 |-INFO in ch.qos.logback.classic.joran.action.LoggerAction - Setting level of logger [big-sur] to INFO
15:59:29,835 |-INFO in ch.qos.logback.classic.joran.action.LoggerAction - Setting additivity of logger [big-sur] to false
15:59:29,835 |-INFO in
ch.qos.logback.core.joran.action.AppenderRefAction - Attaching appender
named [FILE] to Logger[big-sur]
15:59:29,835 |-INFO in
ch.qos.logback.core.joran.action.AppenderRefAction - Attaching appender
named [STDOUT] to Logger[big-sur]
15:59:29,835 |-INFO in
ch.qos.logback.classic.joran.action.RootLoggerAction - Setting level of
ROOT logger to INFO
15:59:29,835 |-INFO in
ch.qos.logback.core.joran.action.AppenderRefAction - Attaching appender
named [FILE] to Logger[ROOT]
15:59:29,835 |-INFO in
ch.qos.logback.core.joran.action.AppenderRefAction - Attaching appender
named [STDOUT] to Logger[ROOT]
15:59:29,835 |-INFO in
ch.qos.logback.classic.joran.action.ConfigurationAction - End of
configuration.
15:59:29,835 |-INFO in
ch.qos.logback.classic.joran.JoranConfigurator@351d00c0 - Registering
current configuration as safe fallback point
我的其他项目在此行之后立即启动springBoot。
我错过了什么?提前谢谢。
答案 0 :(得分:0)
尝试修改版本,例如
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.0.0.RELEASE</version>
<relativePath />
</parent>
答案 1 :(得分:0)
问题出在logback.xml上。它有多个标签具有相同的格式。我已经更新了logback.xml并修复了问题。现在我可以正确启动spring boot应用程序了。
感谢您的每一个时间!
答案 2 :(得分:-1)
您的主类应该从Spring Boot实现CommandLineRunner接口。