运维小弟 运维小弟
首页
  • Ansible
  • Jenkins
  • Argocd
  • mysql
  • redis
  • docker
  • kubernetes
  • zabbix
  • prometheus
  • 工作笔记
  • nginx
  • terraform
关于
首页
  • Ansible
  • Jenkins
  • Argocd
  • mysql
  • redis
  • docker
  • kubernetes
  • zabbix
  • prometheus
  • 工作笔记
  • nginx
  • terraform
关于
  • 服务器断电重启后报XFS文件系统错误
  • yum安装gcc时依赖问题
  • 使用Openssl 自签发IP证书
  • centos7安装telnet-server并升级安装Openssh9.0p1 
  • Maven指定jdk版本打包
  • Centos7 使用nvm配置 多Node.js环境
  • 《Centos》工作笔记
2023-08-06

Maven指定jdk版本打包

# 环境:

  • centos7.9
  • maven-3.6.3
  • jdk8
  • jdk11
  • jenkins2.4

# 背景:

  • A项目需要使用jdk8打包,运行在jdk8 环境上
  • B项目需要使用jdk11打包,运行在jdk11 环境上
  • jenkins 运行在jdk11环境上

# 需求:

需要在 jenkins 上 使用maven3.6.3 同时打包 A 和 B 项目

# 解决方法:

  • 机器上部署jdk8,jdk11
[root@localhost ~]# cd /home/application/

[root@localhost application]# ls -l
total 2
drwxr-xr-x  8 root  root    96 May 10 14:53 jdk-11.0.2
drwxr-xr-x  7 10143 10143  245 Mar 12  2020 jdk1.8.0_251
1
2
3
4
5
6
  • 机器上部署maven3.6.3-A,maven3.6.3-B
[root@localhost ~]# cd /home/application/
[root@localhost application]# ls -l
total 2
drwxr-xr-x  6 root  root    99 May 11 21:29 maven-3.6.3-A
drwxr-xr-x  6 root  root    99 May 11 21:29 maven-3.6.3-B
1
2
3
4
5
  • 修改mvn 二进制可执行脚本,分别指定各自jdk版本的JAVA_HOME
#在mvn脚本的开头,加上一行指定JAVA_HOME路径

[root@localhost bin]# head -10 /home/application/maven-3.6.3-A/bin/mvn
export JAVA_HOME=/home/application/jdk1.8.0_251
#!/bin/sh

# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements.  See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership.  The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License.  You may obtain a copy of the License at


#添加之后保存。在执行mvn -v 命令
[root@localhost bin]# /home/application/maven-3.6.3-A/bin/mvn -v
Apache Maven 3.6.3 (cecedd343002696d0abb50b32b541b8a6ba2883f)
Maven home: /home/application/maven-3.6.3
Java version: 1.8.0_251, vendor: Oracle Corporation, runtime: /home/application/jdk1.8.0_251/jre
Default locale: en_US, platform encoding: UTF-8
OS name: "linux", version: "3.10.0-1160.el7.x86_64", arch: "amd64", family: "unix"



1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
#在mvn脚本的开头,加上一行指定JAVA_HOME路径

[root@localhost bin]# head -10 /home/application/maven-3.6.3-B/bin/mvn
export JAVA_HOME=/home/application/jdk-11.0.2
#!/bin/sh

# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements.  See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership.  The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License.  You may obtain a copy of the License at


#添加之后保存。在执行mvn -v 命令
[root@localhost bin]# /home/application/maven-3.6.3-B/bin/mvn -v
Apache Maven 3.6.3 (cecedd343002696d0abb50b32b541b8a6ba2883f)
Maven home: /home/application/maven-3.6.3-B
Java version: 11.0.2, vendor: Oracle Corporation, runtime: /home/application/jdk-11.0.2
Default locale: en_US, platform encoding: UTF-8
OS name: "linux", version: "3.10.0-1160.el7.x86_64", arch: "amd64", family: "unix"
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
上次更新: 2023/09/06, 17:59:31
centos7安装telnet-server并升级安装Openssh9.0p1 
Centos7 使用nvm配置 多Node.js环境

← centos7安装telnet-server并升级安装Openssh9.0p1  Centos7 使用nvm配置 多Node.js环境→

最近更新
01
Nginx 管理维护规范
09-06
02
Centos7 使用nvm配置 多Node.js环境
08-06
03
在openeuler-22.03 LTS-SP1 上使用kubeadm极速部署Kubernetes 1.24版本集群
08-06
更多文章>
Theme by Vdoing | Copyright © 2019-2023 运维小弟 | fxkjnj.com 版权所有 ( 苏ICP备17042985号-3 )
  • 跟随系统
  • 浅色模式
  • 深色模式
  • 阅读模式