0

I use STS to develop my Spring Boot APP with maven build tool. after successfully checking to run in IDE with the approach of run as spring boot app and learning spring boot reference documentation But when using CMD with maven directive:mvn clean install,it failed with a word I have ever heard before 'surefire'.

Sure,I should post my pom.xml and spring boot class,in addition to that my production env doesn't have the the same password,how should I make it package successfully when packaging

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>

And application class

@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();
             //需要初始化一些用户信息以备测试
             
          
         };
 }
}

log info

[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

Occasionally,I build a war successfully with no reason,Hell,but when I rebuild it it failed

1 Answers1

0

STS IDE Window ->preference->java->Installed JRE->add->Standard VM->choose the JDK path,and right click maven->Update Project.ALL DONE.every time your project with a red cross,you can update your project because of maven pom.xml change.