cmd:No compiler is provided in this environment. Perhaps you are running on a JRE rather than a JDK?

My project is springboot development, with the idea of ​​development tools:

First, let's take a look at my package configuration:

 

<!--打war包第一步-->添加依赖:
<dependency>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-tomcat</artifactId>
    <scope>provided</scope>
</dependency>
<dependency>
    <groupId>javax.servlet</groupId>
    <artifactId>javax.servlet-api</artifactId>
    <scope>provided</scope>
</dependency>


将build改成:
<build>

    <finalName>myweb</finalName><!--打war包第二步-->
    <plugins>
        <plugin> 

            <!--打war包第三步-->
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-war-plugin</artifactId>
            <configuration>
                <failOnMissingWebXml>false</failOnMissingWebXml>
            </configuration>
        </plugin>
    </plugins>
</build>


<-! Fight the war package Step 4 -> Add:
<Packaging> war </ Packaging>


<-! Fight the war package Step 5 -> master boot class needs to inherit something, and rewrite:
@SpringBootApplication
public class MywebApplication the extends SpringBootServletInitializer {
    / **
     * need to deploy web projects labeled as war package to run outside tomcat when the need to change the start-up mode
     * /
    @Override
    protected SpringApplicationBuilder Configure (SpringApplicationBuilder Builder) {
        return builder.sources (MywebApplication.class);
    }
 
    public static void main (String [] args) {
        SpringApplication.run (MywebApplication.class, args);
    }
 
}

I am using cmd project package when appeared as the title that mistake, the Internet a bunch of garbage answer, eventually found a positive solution, I've re-installed the jdk, wrong to tell us you are sure you are using the jre instead jdk ? obviously we want to be able to configure the local maven packaged jdk, we download a good jdk, will first go to install jdk, then will follow jre, we should pay special attention both to separate out: we need to pay special attention to the configuration environment variable JAVA_HOME.

We need to add a line to set the mvn.cmd file in the maven bin directory: add to the first line.

Test: Use the cmd enter mvn -version command:

I re-downloaded jdk8_241 version. Jdk we can see that the information is downloaded jdk, it seems valid configuration, runtime and our re-download the jdk version.

If you still jdk previous version, is probably a problem with the configuration, you need to pay attention to that, we need to move on environment variables jdk the configuration of the first line:

Well, now in use cmd: mvn clean package to package, no problem.

Published 753 original articles · won praise 72 · views 130 000 +

Guess you like

Origin blog.csdn.net/qq_41723615/article/details/104874707