zoukankan      html  css  js  c++  java
  • Maven工程的JDK版本配置

    一,已经存在的Maven工程JDK版本的修改

          <plugins>

                <!-- java编译插件 -->
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-compiler-plugin</artifactId>
                    <version>3.2</version>
                    <configuration>
                        <source>1.8</source>
                        <target>1.8</target>
                        <encoding>UTF-8</encoding>
                    </configuration>
                </plugin>
            </plugins>

       注:修改配置后,点击maven菜单下的update project... 后jdk版本会自动更正。

    二、新Maven工程的JDK版本的指定

    在maven的安装目录找到settings.xml文件,在里面添加如下代码 

      <!-- 默认jdk版本1.8 -->
      <profile>    
          <id>jdk-1.8</id>    
             <activation>    
                  <activeByDefault>true</activeByDefault>    
                  <jdk>1.8</jdk>    
              </activation>    
           <properties>    
                <maven.compiler.source>1.8</maven.compiler.source>    
                <maven.compiler.target>1.8</maven.compiler.target>    
                <maven.compiler.compilerVersion>1.8</maven.compiler.compilerVersion>    
            </properties>    
       </profile> 

    有了这个配置后,每次生成工程是,JDK版本会固定在1.8。

    三、配置Maven的中央仓库

    <mirrors>
        <!-- mirror
         | Specifies a repository mirror site to use instead of a given repository. The repository that
         | this mirror serves has an ID that matches the mirrorOf element of this mirror. IDs are used
         | for inheritance and direct lookup purposes, and must be unique across the set of mirrors.
         |
        <mirror>
          <id>mirrorId</id>
          <mirrorOf>repositoryId</mirrorOf>
          <name>Human Readable Name for this Mirror.</name>
          <url>http://my.repository.com/repo/path</url>
        </mirror>
         -->
        <!-- 阿里云仓库 -->
              <mirror>
                  <id>alimaven</id>
                  <mirrorOf>central</mirrorOf>
                 <name>aliyun maven</name>
                 <url>http://maven.aliyun.com/nexus/content/repositories/central/</url>
             </mirror>


         <!-- 中央仓库2 -->
             <mirror>
                 <id>repo2</id>
                 <mirrorOf>central</mirrorOf>
                 <name>Human Readable Name for this Mirror.</name>
                 <url>http://repo2.maven.org/maven2/</url>
             </mirror>

         
             <!-- 中央仓库1 -->
             <mirror>
                 <id>repo1</id>
                 <mirrorOf>central</mirrorOf>
                 <name>Human Readable Name for this Mirror.</name>
                 <url>http://repo1.maven.org/maven2/</url>
             </mirror>
        
      </mirrors>

    四、配置Maven的本地仓库

  • 相关阅读:
    7-9 红色警报 (25 分) 数据结构连通分量应用
    & | ^运算
    Codeblocks自动代码格式化快捷键(自带)
    网络攻击与防御实验四
    网络攻击与防御实验三
    网络攻击与防御实验二
    网络攻击与防御实验一
    C语言实验7
    C语言实验6
    C语言实验5
  • 原文地址:https://www.cnblogs.com/zhangxj/p/9537170.html
Copyright © 2011-2022 走看看