mave packages and compiles the jdk version generated by java / the solution for the low jdk version of the Maven project when refreshing/importing the project

But when we update-project-configration, the version changes back. 2. Solutions

































2.1 Scheme 1 After adding the following configuration, the solution to update project configuration

[html] view plain copy
is to add 
    <build> 
    <pluginManagement> 
        <plugins> 
         <plugin>   
            <groupId>org.apache.maven in maven's pom.xml. plugins</groupId>   
            <artifactId>maven-compiler-plugin</artifactId>   
            <configuration>   
                <source>1.7</source>   
                <target>1.7</target>   
            </configuration>   
        </plugin>   
        </plugins> 
    </ pluginManagement> 
    </build> 


2. 2 Scheme 2

2.2.1 Note: The maven dependency of eclipse must be external





在安装目录的D:\apache-maven-3.0.5\conf下的settings.xml中插入:红色部分

[html] view plain copy
<profiles> 
    <!-- profile 
     | Specifies a set of introductions to the build process, to be activated using one or more of the 
     | mechanisms described above. For inheritance purposes, and to activate profiles via <activatedProfiles/> 
     | or the command line, profiles have to have an ID that is unique. 
     | 
     | An encouraged best practice for profile identification is to use a consistent naming convention 
     | for profiles, such as 'env-dev', 'env-test', 'env-production', 'user-jdcasey', 'user-brett', etc. 
     | This will make it more intuitive to understand what the set of introduced profiles is attempting 
     | to accomplish, particularly when you only have a list of profile id's for debug. 
     | 
     | This profile example uses the JDK version to trigger activation, and provides a JDK-specific repo. 
    <profile> 
      <id>jdk-1.7</id> 
 
      <activation> 
        <jdk>1.7</jdk> 
      </activation> 
 
      <repositories> 
        <repository> 
          <id>jdk17</id> 
          <name>Repository for JDK 1.7 builds</name> 
          <url>http://www.myhost.com/maven/jdk17</url> 
          <layout>default</layout> 
          <snapshotPolicy>always</snapshotPolicy> 
        </repository> 
      </repositories> 
    </profile> 
    --> 
    <span style="color:#FF0000;"><span style="color:#FF0000;"><profile>   
    <id>jdk17</id>   
    <activation>   
        <activeByDefault>true</activeByDefault>   
        <jdk>1.7</jdk>   
    </activation>   
    <properties>   
        <maven.compiler.source>1.7</maven.compiler.source>   
        <maven.compiler.target>1.7</maven.compiler.target>   
        <maven.compiler.compilerVersion>1.7</maven.compiler.compilerVersion>   
    </properties>    
</profile></span></span>  
 
    <!-- 
     | Here is another profile, activated by the system property 'target-env' with a value of 'dev', 
     | which provides a specific path to the Tomcat instance. To use this, your plugin configuration 
     | might hypothetically look like: 
     | 
     | ... 
     | <plugin> 
     |   <groupId>org.myco.myplugins</groupId> 
     |   <artifactId>myplugin</artifactId> 
     |    
     |   <configuration> 
     |     <tomcatLocation>${tomcatPath}</tomcatLocation> 
     |   </configuration> 
     | </plugin> 
     | ... 
     | 
     | NOTE: If you just wanted to inject this configuration whenever someone set 'target-env' to 
     |       anything, you could just leave off the <value/> inside the activation-property. 
     | 
    <profile> 
      <id>env-dev</id> 
 
      <activation> 
        <property> 
          <name>target-env</name> 
          <value>dev</value> 
        </property> 
      </activation> 
 
      <properties> 
        <tomcatPath>/path/to/tomcat/instance</tomcatPath> 
      </properties> 
    </profile> 
    --> 
  </profiles> 


The second configuration is a global configuration, and the first is a configuration for a project, which you can choose to use in development as needed.

Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=326894448&siteId=291194637