当前位置: 首页 > news >正文

Centos7 maven 安装

maven 下载省略
sudo mkdir -p /usr/local/maven
tar -zxvf apache-maven-3.9.10-bin.tar.gz -C /usr/local/maven/

/usr/local/maven/apache-maven-3.9.10/bin
sudo vi /etc/profile.d/maven.sh

export JAVA_HOME=/usr/lib/jvm/jdk-17  
export M2_HOME=/usr/local/maven/apache-maven-3.9.10
export MAVEN_HOME=/usr/local/maven/apache-maven-3.9.10
export PATH=${M2_HOME}/bin:${PATH}

source /etc/profile
# 或者重新登录

mvn -version


代码中使用时,在pom.xml中配置
jdk 8 版本
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.1</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
<fork>true</fork>
<executable>${JAVA_HOME}/bin/javac</executable>
</configuration>
</plugin>
</plugins>
</build>

=================================================
jdk 17 的基本配置

<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.11.0</version>
<configuration>
<source>17</source>
<target>17</target>
<encoding>UTF-8</encoding>
</configuration>
</plugin>
</plugins>
</build>

在上一步的基础上,指定JDK路径的配置
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.11.0</version>
<configuration>
<source>17</source>
<target>17</target>
<fork>true</fork>
<executable>${JAVA_HOME}/bin/javac</executable>
<encoding>UTF-8</encoding>
</configuration>
</plugin>
</plugins>
</build>


完整配置(包含编译器参数)
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.11.0</version>
<configuration>
<source>17</source>
<target>17</target>
<fork>true</fork>
<executable>${JAVA_HOME}/bin/javac</executable>
<encoding>UTF-8</encoding>
<compilerArgs>
<arg>-parameters</arg>
<arg>-Xlint:unchecked</arg>
<arg>-Xlint:deprecation</arg>
</compilerArgs>
<showWarnings>true</showWarnings>
<showDeprecation>true</showDeprecation>
</configuration>
</plugin>
</plugins>
</build>


多版本兼容配置(如果需要)
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.11.0</version>
<configuration>
<source>17</source>
<target>17</target>
<fork>true</fork>
<executable>${env.JAVA_HOME_17}/bin/javac</executable>
<compilerArgs>
<!-- 启用预览特性(如果需要) -->
<!-- <arg>--enable-preview</arg> -->
</compilerArgs>
<encoding>UTF-8</encoding>
</configuration>
</plugin>
</plugins>
</build>

属性方式配置
<properties>
<maven.compiler.source>17</maven.compiler.source>
<maven.compiler.target>17</maven.compiler.target>
<maven.compiler.compilerVersion>17</maven.compiler.compilerVersion>
<maven.compiler.fork>true</maven.compiler.fork>
<maven.compiler.executable>${JAVA_HOME}/bin/javac</maven.compiler.executable>
</properties>

<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.11.0</version>
</plugin>
</plugins>
</build>

推荐使用第一种基本配置,除非你有特殊需求需要指定具体的JDK路径

http://www.dtcms.com/a/462780.html

相关文章:

  • 深入了解linux网络—— 自定义协议(上)
  • 大连网站制作最好的公司建设企业网站得花多少
  • 服装公司网站源码给网站做seo的价格
  • 购买型网站建设青岛网站建设公司好找吗
  • 在网站建设中遇到的问题手工制作国庆节作品图片
  • 了游*薄俐仔斗哆消仔*游戏程序系统方案
  • jsp网站加载慢开发一款app的公司
  • 如何建设网站pdf下载个人网页制作成品代码免费
  • 邢台网站建设多少钱WordPress考试
  • 网站的集约化建设锦江建设和交通局网站
  • 长沙建网站企业网站建设流程共有几个阶段
  • 做网站人家直接百度能搜到的品牌建设费用
  • MQ 面试宝典
  • 《棒球运动规则》一级运动员年龄限制·棒球1号位
  • 中国建设银行网站 个人西部数码网站管理助手 提权
  • Linux基本指令(下)
  • 手机网站用什么软件开发html5 企业网站
  • IDEA在plugins里搜不到mybatisx插件的解决方法
  • 广州网站建设多少钱深圳网上申请个人营业执照
  • 高端响应式网站建设wordpress动态插件
  • fastadmin列表头部加按钮,点击弹出窗口提交数据保存
  • 网站进行中英文转换怎么做新手销售怎么和客户交流
  • MySQL索引调优之索引顺序是否应该“匹配查询书写顺序”?
  • 安阳网站建设开发用五百丁做名字的简历网站
  • 企业做网站的注意事项沈阳商城网站开发
  • 堆:数组中的第K个最大数
  • 如何添加网站 ico图标小游戏开发需要多少钱
  • printf输出乱码的解决办法
  • 汕头做网站优化的公司两个wordpress
  • 网站域名在哪里如何建立一个免费的网站