【发布时间】:2016-03-04 01:26:50
【问题描述】:
我有多个使用 CommandLineRunner 运行应用程序的类。但是当我使用 spring-boot-maven-plugin 启动应用程序时,所有的类都被一个接一个地调用。即使我将类作为主要方法运行,也会发生这种情况。我该如何克服这一点。任何帮助将不胜感激。
在pom中使用下面的代码来识别main方法
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<version>1.2.4.RELEASE</version>
<configuration>
<mainClass>com.Foo</mainClass>
<layout>ZIP</layout>
</configuration>
<executions>
<execution>
<goals>
<goal>repackage</goal>
</goals>
</execution>
</executions>
</plugin>
【问题讨论】:
-
这就是
CommandLineRunner接口的用途。如果您不希望 Spring 调用这些类的 run 方法,请停止实现该接口。 -
@ESala 感谢您的回复。我正在寻找任何选项来覆盖此行为。
标签: java spring maven spring-boot