maven - 在war中部署Spring Boot APP到外部tomcat
问题描述
我使用 STS 使用 maven 构建工具开发我的 Spring Boot APP。在使用作为 Spring Boot 应用程序运行并学习 Spring Boot 参考文档的方法成功检查在 IDE 中运行之后但是当使用带有 maven 指令的 CMD:mvn clean install 时,它失败了,因为我在“surefire”之前听过一个词。
当然,我应该发布我的pom.xml和spring boot类,除了我的生产环境没有相同的密码,我应该如何在打包时成功打包
POM.xml
<?xml version="1.0" encoding="UTF-8"?>
<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.oneslide</groupId>
<artifactId>RestfulCheck</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>war</packaging>
<name>RestfulCheck</name>
<description>Demo project for Spring Boot</description>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.0.1.RELEASE</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<java.version>1.8</java.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-thymeleaf</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-tomcat</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
</project>
和应用类
@SpringBootApplication
@EnableConfigurationProperties(StorageProperties.class)
public class RestfulCheckApplication extends SpringBootServletInitializer{
public static void main(String[] args) throws Exception{
SpringApplication.run(RestfulCheckApplication.class, args);
}
@Override
protected SpringApplicationBuilder configure(SpringApplicationBuilder application) {
return application.sources(RestfulCheckApplication.class);
}
@Bean
CommandLineRunner init(StorageService storageService) {
return (args) -> {
//storageService.deleteAll();
storageService.init();
//popu.populate();
//需要初始化一些用户信息以备测试
};
}
}
日志信息
[INFO] Scanning for projects...
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building RestfulCheck 0.0.1-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- maven-resources-plugin:3.0.1:resources (default-resources) @ RestfulCheck ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Copying 1 resource
[INFO] Copying 139 resources
[INFO]
[INFO] --- maven-compiler-plugin:3.7.0:compile (default-compile) @ RestfulCheck ---
[INFO] Changes detected - recompiling the module!
[INFO] Compiling 28 source files to D:\workbunch\oneslideicywater-RestfulCheck-plainProfile\RestfulCheck\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.718 s
[INFO] Finished at: 2018-05-13T16:27:18+08:00
[INFO] Final Memory: 22M/228M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.7.0:compile (default-compile) on project RestfulCheck: 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
偶尔,我无缘无故地成功建立了一场战争,见鬼,但是当我重建它时它失败了
解决方案
STS IDE Window ->preference->java->Installed JRE->add->Standard VM->选择JDK路径,然后右键maven->Update Project.ALL DONE。每次你的项目用红叉,你可以由于 maven pom.xml 更改而更新您的项目。
推荐阅读
- python - 使用一个 yaml 中的变量并在另一个 yaml 中替换
- vue.js - 在 Vue.js 中为您的组件道具添加描述/提示
- java - 用于验证名称的正则表达式
- python - CS 231n:Softmax 实现误差的梯度
- python-3.x - 如何将不和谐昵称更改为用户使用机器人 discord.py 编写的任何内容
- excel - 带有数组宏的奇怪维度
- html - when i press f12 to see my mobile design i have a space in blank on the left - CSS
- slatejs - why does slatejs image-upload example crash after uploading an image
- sql - SQL Server big tables or store data in a xml field
- php - PHP Get peak from dataset with value and timestamp