我使用STS使用maven构建工具开发我的Spring Boot APP。 使用"作为 Spring 启动应用程序运行"的方法成功检查在 IDE 中运行并学习 Spring 启动参考文档后 但是当使用带有maven指令的CMD时:mvn全新安装,它失败了 我以前听说过"万无一失"。
当然,我应该发布我的pom.xml和春季启动类,除此之外,我的生产环境没有相同的密码,我应该如何使其打包 包装时成功
聚甲醛.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:workbunchoneslideicywater-RestfulCheck-plainProfileRestfulChecktargetclasses
[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 窗口 ->首选项->java->已安装 JRE->add->Standard VM->选择 JDK 路径,然后右键单击 maven->Update Project.ALL DONE.每次你的项目带有红叉时,你都可以因为 maven pom .xml而更新你的项目更改。