Spring CommandLineRunner不与WAR类依赖项一起运行

时间:2019-04-01 15:08:47

标签: java spring maven war

因此,我试图从内置到战争项目中的本地项目中导入类。但是,当将此依赖项添加到Maven时,它将不再运行Spring CommandLineRunner run函数。

破坏代码的示例战争依赖项:

<dependency>
   <groupId>com.company<groupId>
   <artifactId>artifact<artifactId>
   <version>1.0.1-SNAPSHOT<version>
   <classifier>classes<classifier>
<dependency>

未运行的Java代码:

public class App implements CommandLineRunner
{
    public static void main( String[] args )
    {
        System.out.println( "Hello World!" );
        new SpringApplication(App.class).run(App.class, args);
    }

       @Override
       public void run(String... arg0) throws Exception {
             System.out.println("HELLO WORLD");
       }
}

因此,当添加了上面的maven依赖项时,它会显示Spring标语,但在其下方则不显示任何其他输出。

0 个答案:

没有答案