解决方法:
- 在父工程中将spring-boot的maven插件,替换为maven原始
-
//Springboot的maven插件 <plugin> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-maven-plugin</artifactId> <version>${spring-boot.version}</version> <executions> <execution> <goals> <goal>build-info</goal> </goals> </execution> </executions> </plugin> ----------------------------------------------------------------------------- //原始maven插件 <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-compiler-plugin</artifactId> <version>3.3</version> <configuration> <source>1.8</source> <target>1.8</target> <fork>true</fork> <verbose>true</verbose> <encoding>UTF-8</encoding> <meminitial>256m</meminitial> <maxmem>1024m</maxmem> </configuration> </plugin>
问题原因:
-
1. 官网地址: https://docs.spring.io/spring-boot/docs/current/reference/html/build-tool-plugins-maven-plugin.html#build-tool-plugins-maven-packaging 2. 官网解释: Once spring-boot-maven-plugin has been included in your pom.xml, it automatically tries to rewrite archives to make them executable by using the spring-boot:repackage goal. You should configure your project to build a jar or war (as appropriate) by using the usual packaging element, as shown in the。 大致意思: 如果使用spring-boot-maven-plugin, 在打包的时候,执行的是: spring-boot:repackage。这样就会使用springboot的启动原则,查找main()方法。 但换做原生的maven-plugin,则执行: mvn package。(不去查找main()方法)