1. 程式人生 > >【spring Boot】2.在Myecplise上把spring Boot項目打包 war包和jar包

【spring Boot】2.在Myecplise上把spring Boot項目打包 war包和jar包

aps let failed htm 報錯 聲明 執行 spa oss

========================================================第一部分=============================================================

第一部分:使用maven項目中自帶的插件,將maven的web項目打包成war包

使用的項目是上一章中的maven項目,原封不動

看一下pom.xml文件

技術分享
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation
="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> <modelVersion>4.0.0</modelVersion> <groupId>com.sxd.springBootExample</groupId> <artifactId>firstSpringBootExample</artifactId> <version>0.0.1-SNAPSHOT</version> <packaging>
war</packaging> <build> <plugins> <plugin> <artifactId>maven-war-plugin</artifactId> <configuration> <version>3.0</version> </configuration> </plugin> </
plugins> </build> <!-- 引入parent項目,其實就是一個項目jar,版本自己在http://mvnrepository.com/search?q=spring-boot-starter-parent 選擇即可 --> <parent> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-parent</artifactId> <version>1.5.7.RELEASE</version> </parent> <!-- 要跑起來一個web項目,就引入這一個jar即可,版本不用寫,parent中已經聲明了的 --> <dependencies> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-web</artifactId> </dependency> </dependencies> </project>
View Code

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
View Code

解決方法:http://www.cnblogs.com/sxdcgaq8080/p/7617542.html

4.解決錯誤之後,重新進行打包操作

技術分享

技術分享

5.執行之後結果如下:

技術分享

技術分享

=====================================================第二部分=========================================================

第二部分,使用springBoot提供的插件,將項目打包為jar包

【spring Boot】2.在Myecplise上把spring Boot項目打包 war包和jar包