隨筆-126  評論-247  文章-5  trackbacks-0

          maven 默認(rèn)使用的 jdk 版本

          新建一個 maven 項(xiàng)目,如下 :

          項(xiàng)目左下方出現(xiàn)一個感嘆號,JRE 顯示的是 1.5 版本。解決方式有兩種,一種是配置 pom.xml,一種是配置 settings.xml。

          方式一:settings.xml 配置

          打開 %maven%/conf/settings.xml 文件并編輯它(%maven% 表示 maven 的根目錄) :
          <profiles>
            <profile>
              <id>development</id>
              <activation>
                <jdk>1.7</jdk>
                <activeByDefault>true</activeByDefault>
              </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>
          </profiles>
          找到 <profiles> 節(jié)點(diǎn),并添加如上配置(本機(jī) jdk 1.7.0_79 版本,配置時修改成你本機(jī)的 jdk 版本)。保存并關(guān)閉。重啟 eclipse 即可。
          重啟后配置生效。

          方式二:pom.xml 配置

          在 <build> 節(jié)點(diǎn)添加如下配置(本機(jī) jdk 1.7.0_79 版本,配置時修改成你本機(jī)的 jdk 版本):
          <build>
            <plugins>
              <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <configuration>
                  <source>1.7</source>
                  <target>1.7</target>
                </configuration>
              </plugin>
            </plugins>
          </build>
          配置完成后,需要執(zhí)行一次更新項(xiàng)目配置的動作。選中項(xiàng)目 --> 右鍵 --> Maven --> Update Project(eclipse luna 版本,helios 或
          indigo 版本選擇 Update Project Configuration)。
          pom.xml 僅作用于當(dāng)前項(xiàng)目(每個項(xiàng)目都需要配一次),而 settings.xml 的配置是全局的(僅需要配一次)。以上兩種配置方式中選其一即可。



            
          posted on 2015-06-23 09:45 fancydeepin 閱讀(40989) 評論(0)  編輯  收藏 所屬分類: maven
          主站蜘蛛池模板: 卢氏县| 天祝| 宁乡县| 油尖旺区| 普兰店市| 榆中县| 建阳市| 元谋县| 宣恩县| 盐池县| 新干县| 桓台县| 惠水县| 新和县| 中阳县| 新巴尔虎左旗| 天峻县| 收藏| 治多县| 南投市| 日喀则市| 中西区| 阳朔县| 甘泉县| 灵台县| 贺州市| 虞城县| 武功县| 嘉鱼县| 明水县| 霸州市| 尉犁县| 松阳县| 德令哈市| 明溪县| 芦山县| 桑日县| 山阴县| 衡阳县| 陆丰市| 桓仁|