maven 构建java项目,jdk版本问题
為什么80%的碼農都做不了架構師?>>> ??
使用maven構建Java項目,默認的 jdk 版本是1.5
詳情見官方說明:https://maven.apache.org/plugins/maven-compiler-plugin/compile-mojo.html
| source | String | 2.0 | The -source argument for the Java compiler. Default value is:?1.5. User property is:?maven.compiler.source. |
| target | String | 2.1 | The -target argument for the Java compiler. Default value is:?1.5. User property is:?maven.compiler.target. |
| encoding | String | 2.0 | The -encoding argument for the Java compiler. |
如果要指定 jdk 版本,有兩種方式
第一種方式:在maven的settings.xml中指定
<profiles>??????<profile>??<id>JDK1.7</id>??<activation>??<activeByDefault>true</activeByDefault>??</activation>??<properties>??<maven.compiler.source>1.7</maven.compiler.source>??<maven.compiler.target>1.7</maven.compiler.target>??<encoding>UTF-8</encoding>??</properties>??</profile>?? </profiles>??第二種方式:在工程中的pom文件中指定?
方式一:
<properties><maven_compiler_plugin_version>2.32</maven_compiler_plugin_version> </properties><build> <plugins> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-compiler-plugin</artifactId> <version>${maven_compiler_plugin_version}</version> <configuration> <source>1.7</source> <target>1.7</target> <encoding>UTF-8</encoding> </configuration> </plugin> </plugins> </build>方式二:
?<properties><project.build.sourceEncoding>UTF-8</project.build.sourceEncoding><project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding><maven.compiler.source>1.7</maven.compiler.source><maven.compiler.target>1.7</maven.compiler.target></properties>?
轉載于:https://my.oschina.net/ranxi/blog/1623231
總結
以上是生活随笔為你收集整理的maven 构建java项目,jdk版本问题的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 推动开源供应链安全发展 2023中国互联
- 下一篇: 通过七牛云建立私有图床