今天打包父子项目,起先包如下错误
[ERROR] Plugin org.apache.maven.plugins:maven-jar-plugin:2.4 or one of its dependencies could not be resolved: Failure to find org.apache.maven.plugins:maven-jar-plugin:jar:2.4 in http://localhost:8081/nexus/content/groups/public was cached in the local repository, resolution will not be reattempted until the update interval of nexus has elapsed or updates are forced -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/PluginResolutionException
之类的错误
解决办法:在idea中,或者在cmd命令窗口,切换到项目路径下执行
1、执行 mvn clean,之后执行 mvn install
2、成功后,会在target目录下创建 所打的包.war和.war.original
3、打开cmd命令窗口,切换到war包所在路径,输入 java -jar war包,启动项目
4、发现war包在Tomcat中不能启动,Tomcat可以正常运行,不启动项目
原因:springboot项目没有启动类,
解决办法:在springboot启动类同目录下,新建如下类
import org.springframework.boot.builder.SpringApplicationBuilder; import org.springframework.boot.web.servlet.support.SpringBootServletInitializer; /** * 修改启动类,继承 SpringBootServletInitializer 并重写 configure 方法 */ public class SpringBootStartApplication extends SpringBootServletInitializer { @Override protected SpringApplicationBuilder configure(SpringApplicationBuilder builder) { // 注意这里要指向原先用main方法执行的Application启动类 return builder.sources(AdminApplication.class); } }
*其他原因可参考https://yq.aliyun.com/articles/58273