spring Boot2.在Myecplise上把spring Boot项目打包 war包和jar包

Posted Angel挤一挤

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了spring Boot2.在Myecplise上把spring Boot项目打包 war包和jar包相关的知识,希望对你有一定的参考价值。

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

第一部分:使用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 Boot2.在Myecplise上把spring Boot项目打包 war包和jar包的主要内容,如果未能解决你的问题,请参考以下文章

Spring Boot2:使用Spring Boot2集成Mybatis缓存机制

spring boot2

myecplise debug时怎么看源码 和怎么导入项目中框架的源码

spring boot2.0+中添加全局异常捕获

Spring Boot2:使用Spring Boot结合Thymeleaf模板引擎使用总结

Spring Boot2 系列教程 | 实现声明式事务