【DevOps视频笔记】4.Build 阶段 - Maven安装&配置

这篇具有很好参考价值的文章主要介绍了【DevOps视频笔记】4.Build 阶段 - Maven安装&配置。希望对大家有所帮助。如果存在错误或未考虑完全的地方,请大家不吝赐教,您也可以点击"举报违法"按钮提交疑问。

一、Build 阶段工具

二、Operate阶段工具

三、服务器中安装

四、修改网卡信息

  五、安装 jdk 和 maven

Stage1 : 安装 JDK

Stage 2 : 安装 Maven

2-1 : 更换文件夹名称

2-2 : 替换配置文件 settings.xml-

2-3 : 修改settings.xml详情

A. 修改maven仓库地址 - 阿里云

B. 设置JDB 1.8 编译插件,默认是1.5



一、Build 阶段工具

        构建Java项目的工具一般有两种选择,一个是Maven,一个是Gradle。

        这里我们选择 Maven 作为项目的编译工具

        具体安装Maven流程不做阐述,但是需要确保配置好Maven仓库私服以及JDK编译版本。

二、Operate阶段工具

        部署过程,会采用Docker进行部署

三、服务器中安装

jenkins 容器中需要用到如下插件

  • jdk 1.8
  • maven  下载地址

四、修改网卡信息

  • 这里使用的是虚拟机,所以需要修改
vi /etc/sysconfig/network-scripts/ifcfg-ens33

【DevOps视频笔记】4.Build 阶段 - Maven安装&配置,架构师之路-java,devops,笔记,maven

#保存退出

#重启网卡,配置生效
systemctl restart network

  五、安装 jdk 和 maven

  • linux下下载后缀名为 .tar.gz 安装包

Stage1 : 安装 JDK

#Stage1:安装JDK,因为不需要服务器进行编译,所以不用配置环境变量
tar -zxvf jdk-8u202-linux-x64.tar.gz -C /usr/local
# clear 清屏
clear 

Stage 2 : 安装 Maven

#Stage2:安装 Maven
tar -zxvf apache-maven-3.9.4-bin.tar.gz -C /usr/local
2-1 : 更换文件夹名称
  • 作者嫌弃文件名太长,不在意的可以忽略
cd /usr/local
mv jdk1.8.0 202/ jdk/
mv apache-maven-3.9.4/ maven/
2-2 : 替换配置文件 settings.xml-
  • 直接替换如下内容,修改详情请参考 2-3 : 修改settings.xml详情
<?xml version="1.0" encoding="UTF-8"?>

<!--
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

    http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, either express or implied.  See the License for the
specific language governing permissions and limitations
under the License.
-->

<!--
 | This is the configuration file for Maven. It can be specified at two levels:
 |
 |  1. User Level. This settings.xml file provides configuration for a single user,
 |                 and is normally provided in ${user.home}/.m2/settings.xml.
 |
 |                 NOTE: This location can be overridden with the CLI option:
 |
 |                 -s /path/to/user/settings.xml
 |
 |  2. Global Level. This settings.xml file provides configuration for all Maven
 |                 users on a machine (assuming they're all using the same Maven
 |                 installation). It's normally provided in
 |                 ${maven.conf}/settings.xml.
 |
 |                 NOTE: This location can be overridden with the CLI option:
 |
 |                 -gs /path/to/global/settings.xml
 |
 | The sections in this sample file are intended to give you a running start at
 | getting the most out of your Maven installation. Where appropriate, the default
 | values (values used when the setting is not specified) are provided.
 |
 |-->
<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0"
          xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
          xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0 http://maven.apache.org/xsd/settings-1.0.0.xsd">
  <!-- localRepository
   | The path to the local repository maven will use to store artifacts.
   |
   | Default: ${user.home}/.m2/repository
  <localRepository>/path/to/local/repo</localRepository>
  -->
  <localRepository>/usr/local/maven/apache-maven-3.6.3/localRepository</localRepository>

  <!-- interactiveMode
   | This will determine whether maven prompts you when it needs input. If set to false,
   | maven will use a sensible default value, perhaps based on some other setting, for
   | the parameter in question.
   |
   | Default: true
  <interactiveMode>true</interactiveMode>
  -->

  <!-- offline
   | Determines whether maven should attempt to connect to the network when executing a build.
   | This will have an effect on artifact downloads, artifact deployment, and others.
   |
   | Default: false
  <offline>false</offline>
  -->

  <!-- pluginGroups
   | This is a list of additional group identifiers that will be searched when resolving plugins by their prefix, i.e.
   | when invoking a command line like "mvn prefix:goal". Maven will automatically add the group identifiers
   | "org.apache.maven.plugins" and "org.codehaus.mojo" if these are not already contained in the list.
   |-->
  <pluginGroups>
    <!-- pluginGroup
     | Specifies a further group identifier to use for plugin lookup.
    <pluginGroup>com.your.plugins</pluginGroup>
    -->
  </pluginGroups>

  <!-- proxies
   | This is a list of proxies which can be used on this machine to connect to the network.
   | Unless otherwise specified (by system property or command-line switch), the first proxy
   | specification in this list marked as active will be used.
   |-->
  <proxies>
    <!-- proxy
     | Specification for one proxy, to be used in connecting to the network.
     |
    <proxy>
      <id>optional</id>
      <active>true</active>
      <protocol>http</protocol>
      <username>proxyuser</username>
      <password>proxypass</password>
      <host>proxy.host.net</host>
      <port>80</port>
      <nonProxyHosts>local.net|some.host.com</nonProxyHosts>
    </proxy>
    -->
  </proxies>

  <!-- servers
   | This is a list of authentication profiles, keyed by the server-id used within the system.
   | Authentication profiles can be used whenever maven must make a connection to a remote server.
   |-->
  <servers>
    <!-- server
     | Specifies the authentication information to use when connecting to a particular server, identified by
     | a unique name within the system (referred to by the 'id' attribute below).
     |
     | NOTE: You should either specify username/password OR privateKey/passphrase, since these pairings are
     |       used together.
     |
    <server>
      <id>deploymentRepo</id>
      <username>repouser</username>
      <password>repopwd</password>
    </server>
    -->

    <!-- Another sample, using keys to authenticate.
    <server>
      <id>siteServer</id>
      <privateKey>/path/to/private/key</privateKey>
      <passphrase>optional; leave empty if not used.</passphrase>
    </server>
    -->
  </servers>

  <!-- mirrors
   | This is a list of mirrors to be used in downloading artifacts from remote repositories.
   |
   | It works like this: a POM may declare a repository to use in resolving certain artifacts.
   | However, this repository may have problems with heavy traffic at times, so people have mirrored
   | it to several places.
   |
   | That repository definition will have a unique id, so we can create a mirror reference for that
   | repository, to be used as an alternate download site. The mirror site will be the preferred
   | server for that repository.
   |-->
  <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>
	    <name>aliyun maven</name>
	    <url>http://maven.aliyun.com/nexus/content/groups/public/</url>
	    <mirrorOf>central</mirrorOf>
  	</mirror>
  </mirrors>

  <!-- profiles
   | This is a list of profiles which can be activated in a variety of ways, and which can modify
   | the build process. Profiles provided in the settings.xml are intended to provide local machine-
   | specific paths and repository locations which allow the build to work in the local environment.
   |
   | For example, if you have an integration testing plugin - like cactus - that needs to know where
   | your Tomcat instance is installed, you can provide a variable here such that the variable is
   | dereferenced during the build process to configure the cactus plugin.
   |
   | As noted above, profiles can be activated in a variety of ways. One way - the activeProfiles
   | section of this document (settings.xml) - will be discussed later. Another way essentially
   | relies on the detection of a system property, either matching a particular value for the property,
   | or merely testing its existence. Profiles can also be activated by JDK version prefix, where a
   | value of '1.4' might activate a profile when the build is executed on a JDK version of '1.4.2_07'.
   | Finally, the list of active profiles can be specified directly from the command line.
   |
   | NOTE: For profiles defined in the settings.xml, you are restricted to specifying only artifact
   |       repositories, plugin repositories, and free-form properties to be used as configuration
   |       variables for plugins in the POM.
   |
   |-->
  <profiles>
    <!-- profile
     | Specifies a set of introductions to the build process, to be activated using one or more of the
     | mechanisms described above. For inheritance purposes, and to activate profiles via <activatedProfiles/>
     | or the command line, profiles have to have an ID that is unique.
     |
     | An encouraged best practice for profile identification is to use a consistent naming convention
     | for profiles, such as 'env-dev', 'env-test', 'env-production', 'user-jdcasey', 'user-brett', etc.
     | This will make it more intuitive to understand what the set of introduced profiles is attempting
     | to accomplish, particularly when you only have a list of profile id's for debug.
     |
     | This profile example uses the JDK version to trigger activation, and provides a JDK-specific repo.
    <profile>
      <id>jdk-1.4</id>

      <activation>
        <jdk>1.4</jdk>
      </activation>

      <repositories>
        <repository>
          <id>jdk14</id>
          <name>Repository for JDK 1.4 builds</name>
          <url>http://www.myhost.com/maven/jdk14</url>
          <layout>default</layout>
          <snapshotPolicy>always</snapshotPolicy>
        </repository>
      </repositories>
    </profile>
    -->

    <!--
     | Here is another profile, activated by the system property 'target-env' with a value of 'dev',
     | which provides a specific path to the Tomcat instance. To use this, your plugin configuration
     | might hypothetically look like:
     |
     | ...
     | <plugin>
     |   <groupId>org.myco.myplugins</groupId>
     |   <artifactId>myplugin</artifactId>
     |
     |   <configuration>
     |     <tomcatLocation>${tomcatPath}</tomcatLocation>
     |   </configuration>
     | </plugin>
     | ...
     |
     | NOTE: If you just wanted to inject this configuration whenever someone set 'target-env' to
     |       anything, you could just leave off the <value/> inside the activation-property.
     |
    <profile>
      <id>env-dev</id>

      <activation>
        <property>
          <name>target-env</name>
          <value>dev</value>
        </property>
      </activation>

      <properties>
        <tomcatPath>/path/to/tomcat/instance</tomcatPath>
      </properties>
    </profile>
    -->
	<profile>
		<id>jdk8</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>
  </profiles>

  <!-- activeProfiles
   | List of profiles that are active for all builds.
   |
  <activeProfiles>
    <activeProfile>alwaysActiveProfile</activeProfile>
    <activeProfile>anotherAlwaysActiveProfile</activeProfile>
  </activeProfiles>
  -->
	<activeProfiles>
		<activeProfile>jdk8</activeProfile>
	</activeProfiles>
</settings>
2-3 : 修改settings.xml详情
  • a.设置阿里云或华为云仓库地址
  • b. 设置JDB 1.8 编译插件,默认是1.5
cd /usr/local/maven/conf
ls
# logging  settings.xml  toolchains.xml
vi settings.xml
  • :set nu  显示行号
     

【DevOps视频笔记】4.Build 阶段 - Maven安装&配置,架构师之路-java,devops,笔记,maven文章来源地址https://www.toymoban.com/news/detail-669944.html

A. 修改maven仓库地址 - 阿里云
<mirror>
        <id>nexus-aliyun</id>
        <mirrorOf>*</mirrorOf>
        <name>Nexus aliyun</name>
        <url>http://maven.aliyun.com/nexus/content/groups/public</url>
</mirror>
B. 设置JDB 1.8 编译插件,默认是1.5
	<profile>
		<id>jdk8</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>
  • 开启JDK8
	<activeProfiles>
		<activeProfile>jdk8</activeProfile>
	</activeProfiles>

到了这里,关于【DevOps视频笔记】4.Build 阶段 - Maven安装&配置的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处: 如若内容造成侵权/违法违规/事实不符,请点击违法举报进行投诉反馈,一经查实,立即删除!

领支付宝红包 赞助服务器费用

相关文章

  • 【DevOps视频】笔记

    视频官网 

    2023年04月24日
    浏览(35)
  • [DevOps-04] Operate阶段工具

    安装Docker 安装Docker-compose 官网地址: https://www.docker.com 文档地址: Docker Docs 仓库地址: https://hub.docker.com 官方网站 Get Docker | Docker Docs

    2024年02月03日
    浏览(21)
  • Maven学习笔记(单一架构案例)22版

    目录 第一节 创建工程,引入依赖 1 架构 ①架构的概念 ②单一架构 2 创建工程 3 引入依赖 ①搜索依赖信息的网站 ②持久化层所需依赖 ③表述层所需依赖 ④辅助功能所需依赖 ⑤最终完整依赖信息 4 建包  第二节 搭建环境:持久化层 1 数据建模 ①物理建模 ②逻辑建模 2 数据

    2024年02月06日
    浏览(29)
  • 【Android】使用build.gradle.kt配置目标架构(abiFIlters)时报错 Val cannot be reassigned

    传统上我们会使用 groovy 语言的配置文件 build.gradle 来配置: 在app级别的build.gradle中的 android defaultConfig 添加子项 新版本的默认使用 kotlin 语言的配置文件 build.gradle.kt 来配置gradle: 相应地会想到使用下列代码来指定abi: 此时进行sync就会报错: Val cannot be reassigned Type mismatch.

    2024年01月25日
    浏览(37)
  • Maven多模块项目架构配置介绍和实战

    原文地址:https://ntopic.cn/p/2023071501/ 源代码先行: Gitee多模块项目仓库:https://gitee.com/obullxl/ntopic-boot GitHub多模块项目仓库:https://github.com/obullxl/ntopic-boot 我们项目采用的是Maven多模块架构,我发现项目的部分子模块的pom.xml中重复引用了相同的JAR包。很明显,当初在配置Maven模

    2024年02月16日
    浏览(37)
  • 软件测试学习笔记丨持续集成DevOps - Jenkins安装

    本文转自测试人社区,原文链接:https://ceshiren.com/t/topic/30028 通过 war 包安装 通过安装包安装(不推荐) 通过 docker 命令安装(推荐 Linux 环境): docker pull jenkins/jenkins:lts 2.1 ,war包启动(用于调试,不推荐安装): (1), 下载war包后, 进入对应的war下载的目录,通过命令启

    2024年04月09日
    浏览(56)
  • 【DevOps工具篇】 OpenLDAP服务器安装和配置方法

    推荐超级课程: Docker快速入门到精通

    2024年04月16日
    浏览(37)
  • Servlet-搭建个人博客系统(MVC架构模式简介,maven的配置和使用)

    目录 1. MVC架构模式简介 2. maven的配置和使用 3. 项目总述🐻 3.1 🍎Controller层 3.2 🍎Model层 3.3 🍎View层 4. 页面的主要功能实现🐻 4.1 🍎登陆页面(login.html) 4.2 🍎博客列表页面(blog_index.html) 4.3 🍎博客详情页面(blog_detail.html) 4.4 🍎博客编辑页(blog_editor.html) 5.Conto

    2024年02月05日
    浏览(41)
  • 【Maven】002-Maven 安装和配置

    https://maven.apache.org/ https://maven.apache.org/docs/history.html https://mvnrepository.com/ 历史版本列表:https://maven.apache.org/docs/history.html Maven 需要本机安装 Java 环境、必需包含 JAVA_HOME 环境变量! bin :含有 Maven 的运行脚本; boot :含有 plexus-classworlds 类加载器框架; conf :含有 Maven 的核心

    2024年01月17日
    浏览(37)
  • maven之pom中的build标签

            针对整个项目的所有情况都有效。         针对不同的profile配置。 defaultGoal :执行build任务时,如果没有指定目标,将使用的默认值。如上配置:在命令行中执行mvn,则相当于执行mvn install directory :  构建结果输出目录,默认在${basedir}/target目录。 finalName :

    2024年04月14日
    浏览(29)

觉得文章有用就打赏一下文章作者

支付宝扫一扫打赏

博客赞助

微信扫一扫打赏

请作者喝杯咖啡吧~博客赞助

支付宝扫一扫领取红包,优惠每天领

二维码1

领取红包

二维码2

领红包