本文共 3845 字,大约阅读时间需要 12 分钟。
========================================================第一部分=============================================================
第一部分:使用maven项目中自带的插件,将maven的web项目打包成war包
使用的项目是上一章中的maven项目,原封不动
看一下pom.xml文件
4.0.0 com.sxd.springBootExample firstSpringBootExample 0.0.1-SNAPSHOT war maven-war-plugin 3.0 org.springframework.boot spring-boot-starter-parent 1.5.7.RELEASE org.springframework.boot spring-boot-starter-web
1.右键项目--->Debugs As--->Debugs Configurations
2.跟着步骤走
3.报错啦:
No compiler is provided in this environment. Perhaps you are running on a JRE rather than a JDK
[INFO] Scanning for projects...[INFO] [INFO] Using the builder org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder with a thread count of 1[INFO] [INFO] ------------------------------------------------------------------------[INFO] Building firstSpringBootExample 0.0.1-SNAPSHOT[INFO] ------------------------------------------------------------------------[INFO] [INFO] --- maven-clean-plugin:2.6.1:clean (default-clean) @ firstSpringBootExample ---[INFO] Deleting D:\workspace2\firstSpringBootExample\target[INFO] [INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ firstSpringBootExample ---[INFO] Using 'UTF-8' encoding to copy filtered resources.[INFO] Copying 0 resource[INFO] Copying 0 resource[INFO] [INFO] --- maven-compiler-plugin:3.1:compile (default-compile) @ firstSpringBootExample ---[INFO] Changes detected - recompiling the module![INFO] Compiling 1 source file to D:\workspace2\firstSpringBootExample\target\classes[INFO] -------------------------------------------------------------[ERROR] COMPILATION ERROR : [INFO] -------------------------------------------------------------[ERROR] No compiler is provided in this environment. Perhaps you are running on a JRE rather than a JDK?[INFO] 1 error[INFO] -------------------------------------------------------------[INFO] ------------------------------------------------------------------------[INFO] BUILD FAILURE[INFO] ------------------------------------------------------------------------[INFO] Total time: 2.398 s[INFO] Finished at: 2017-10-01T17:41:26+08:00[INFO] Final Memory: 13M/232M[INFO] ------------------------------------------------------------------------[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.1:compile (default-compile) on project firstSpringBootExample: Compilation failure[ERROR] No compiler is provided in this environment. Perhaps you are running on a JRE rather than a JDK?[ERROR] -> [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/MojoFailureException
解决方法:http://www.cnblogs.com/sxdcgaq8080/p/7617542.html
4.解决错误之后,重新进行打包操作
5.执行之后结果如下:
=====================================================第二部分=========================================================
第二部分,使用springBoot提供的插件,将项目打包为jar包