文章详情

短信预约-IT技能 免费直播动态提醒

请输入下面的图形验证码

提交验证

短信预约提醒成功

Maven安装及配置

2023-10-04 20:47

关注

1.下载

Maven – Download Apache Maven

geg4ghe56hbfdhsghdf

2.安装

maven压缩包解压到一个没有中文,空格或其他特殊字符的文件夹内即可使用。

fge3467u34q2grthty

3.配置环境变量

1.右键此电脑->属性->高级系统设置->环境变量

fersd56y234wwger

2.新建系统变量MAVEN_HOME

sda54yfcthj6re453gv

3.编辑系统变量Path,添加变量值%MAVEN_HOME%\bin

sfa45grtaefj6345rgv

4.验证安装是否成功,win+R运行cmd,输入mvn -v,如图所示则配置成功

grtesf345t67ugerswehty

4.配置本地仓库

1.在maven的安装目录下创建一个repository文件夹用作本地仓库(一般习惯将仓库地址和maven安装目录放置在一起)。

rghty345thgrtyhet

2.修改本地仓库地址

(1)在Maven安装目录conf目录下找到settings.xml配置文件打开

dghjsrtg345tyh7jq3tgr

(2)找到 标签节点并将其改为本地仓库地址

htyrd4y6j6aergfjuhyt

5.配置私服

(1)在Maven安装目录conf目录下找到settings.xml配置文件打开

dghjsrtg345tyh7jq3tgr

(2)找到 标签节点并将其改为如下:

将原有注释

//阿里云<mirror>  <id>aliyunmavenid>  <mirrorOf>*mirrorO>  <name>阿里云公共仓库name>  <url>https://maven.aliyun.com/repository/publicurl>mirror>## 或//网易<mirror>    <id>nexus-163id>    <mirrorOf>*mirrorOf>    <name>Nexus 163name>    <url>http://mirrors.163.com/maven/repository/maven-public/url>mirror>## 或//腾讯云<mirror>    <id>nexus-tencentyunid>    <mirrorOf>*mirrorOf>    <name>Nexus tencentyunname>    <url>http://mirrors.cloud.tencent.com/nexus/repository/maven-public/url>mirror> 

faew56yey34qgvrtrgh5

6.项目结构

没有的 javaresources、或 webapp 要添加进去

ytsedebbetr

7.IDEA配置

[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-0GG400qK-1675758562809)(null)]

本地获取,添加 -DarchetypeCatalog=internal

[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-USnCWraM-1675758552834)(C:\Users\Administrator\AppData\Roaming\Typora\typora-user-images\image-20230207110348941.png)]

8.pom文件配置

<project xmlns="http://maven.apache.org/POM/4.0.0"         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd ">        <parent>                <artifactId>xxxartifactId>                <groupId>xxxgroupId>                <version>xxxversion>                <relativePath>xxxrelativePath>    parent>        <modelVersion> 4.0.0 modelVersion>        <groupId>xxxgroupId>        <artifactId>xxxartifactId>        <packaging> jar packaging>        <version> 1.0-SNAPSHOT version>        <name> xxx-maven name>        <url> http://maven.apache.org url>        <description> A maven project to study maven. description>        <prerequisites>                <maven>maven>    prerequisites>        <issueManagement>                <system> jira system>                <url> http://jira.baidu.com/banseon url>    issueManagement>        <ciManagement>                <system>system>                <url>url>                <notifiers>                        <notifier>                                <type>type>                                <sendOnError>sendOnError>                                <sendOnFailure>sendOnFailure>                                <sendOnSuccess>sendOnSuccess>                                <sendOnWarning>sendOnWarning>                                <address>address>                                <configuration>configuration>            notifier>        notifiers>    ciManagement>        <inceptionYear />        <mailingLists>                <mailingList>                        <name> Demo name>                        <post> banseon@126.com post>                        <subscribe> banseon@126.com subscribe>                        <unsubscribe> banseon@126.com unsubscribe>                        <archive> http:/hi.baidu.com/banseon/demo/dev/ archive>        mailingList>    mailingLists>        <developers>                <developer>                        <id> HELLO WORLD id>                        <name> banseon name>                        <email> banseon@126.com email>                        <url>url>                        <roles>                <role> Project Manager role>                <role> Architect role>            roles>                        <organization> demo organization>                        <organizationUrl> http://hi.baidu.com/xxx organizationUrl>                        <properties>                <dept> No dept>            properties>                        <timezone> -5 timezone>        developer>    developers>        <contributors>                <contributor>                        <name>name>                        <email>email>                        <url>url>                        <organization>organization>                        <organizationUrl>organizationUrl>                        <roles>                <role> Project Manager role>                <role> Architect role>            roles>                        <timezone>timezone>                        <properties>                <dept> No dept>            properties>        contributor>    contributors>        <licenses>                <license>                        <name> Apache 2 name>                        <url> http://www.baidu.com/banseon/LICENSE-2.0.txt url>                        <distribution> repo distribution>                        <comments> A business-friendly OSS license comments>        license>    licenses>        <scm>                <connection>            scm:svn:http://svn.baidu.com/banseon/maven/banseon/banseon-maven2-trunk(dao-trunk)        connection>                <developerConnection>            scm:svn:http://svn.baidu.com/banseon/maven/banseon/dao-trunk        developerConnection>                <tag>tag>                <url> http://svn.baidu.com/banseon url>    scm>        <organization>                <name> demo name>                <url> http://www.baidu.com/banseon url>    organization>        <build>                <sourceDirectory>sourceDirectory>                <scriptSourceDirectory>scriptSourceDirectory>                <testSourceDirectory>testSourceDirectory>                <outputDirectory>outputDirectory>                <testOutputDirectory>testOutputDirectory>                <extensions>                        <extension>                                <groupId>groupId>                                <artifactId>artifactId>                                <version>version>            extension>        extensions>                <defaultGoal>defaultGoal>                <resources>                        <resource>                                <targetPath>targetPath>                                <filtering>filtering>                                <directory>directory>                                <excludes>                    <exclude>exclude>                excludes>            resource>        resources>                <testResources>                        <testResource>                                <targetPath>targetPath>                                <filtering>filtering>                                <directory>directory>                                <excludes>                    <exclude>exclude>                excludes>            testResource>        testResources>                <directory>directory>                <finalName>finalName>                <filters>filters>                <pluginManagement>                        <plugins>                                <plugin>                                        <groupId>groupId>                                        <artifactId>artifactId>                                        <version>version>                                        <extensions>true/falseextensions>                                        <executions>                                                <execution><id>id><phase>phase><goals>goals><inherited>true/falseinherited><configuration>configuration>                        execution>                    executions>                                        <dependencies>                                                <dependency>                        dependency>                    dependencies>                                        <inherited>true/falseinherited>                                        <configuration>configuration>                plugin>            plugins>        pluginManagement>                <plugins>                        <plugin>                                <groupId>groupId>                                <artifactId>artifactId>                                <version>version>                                <extensions>true/falseextensions>                                <executions>                                        <execution>                                                <id>id>                                                <phase>phase>                                                <goals>goals>                                                <inherited>true/falseinherited>                                                <configuration>configuration>                    execution>                executions>                                <dependencies>                                        <dependency>                    dependency>                dependencies>                                <inherited>true/falseinherited>                                <configuration>configuration>            plugin>        plugins>    build>        <profiles>                <profile>                        <id>id>                        <activation>                                <activeByDefault>true/falseactiveByDefault>                                <jdk>jdk版本,如:1.7jdk>                                <os>                                        <name> Windows XP name>                                        <family> Windows family>                                        <arch> x86 arch>                                        <version> 5.1.2600 version>                os>                                <property>                                        <name> mavenVersion name>                                        <value> 2.0.3 value>                property>                                <file>                                        <exists> /usr/local/hudson/hudson-home/jobs/maven-guide-zh-to-production/workspace/ exists>                                        <missing> /usr/local/hudson/hudson-home/jobs/maven-guide-zh-to-production/workspace/ missing>                file>            activation>                        <build>                <defaultGoal />                <resources>                    <resource>                        <targetPath>targetPath>                        <filtering>filtering>                        <directory>directory>                        <includes><include>include>                        includes>                        <excludes><exclude>exclude>                        excludes>                    resource>                resources>                <testResources>                    <testResource>                        <targetPath>targetPath>                        <filtering>filtering>                        <directory>directory>                        <includes><include>include>                        includes>                        <excludes><exclude>exclude>                        excludes>                    testResource>                testResources>                <directory>directory>                <finalName>finalName>                <filters>filters>                <pluginManagement>                    <plugins>                                                <plugin><groupId>groupId><artifactId>artifactId><version>version><extensions>true/falseextensions><executions>    <execution>        <id>id>        <phase>phase>        <goals>goals>        <inherited>true/falseinherited>        <configuration>configuration>    execution>executions><dependencies>        <dependency>    dependency>dependencies><goals>goals><inherited>true/falseinherited><configuration>configuration>                        plugin>                    plugins>                pluginManagement>                <plugins>                                        <plugin>                        <groupId>groupId>                        <artifactId>artifactId>                        <version>version>                        <extensions>true/falseextensions>                        <executions><execution>    <id>id>    <phase>phase>    <goals>goals>    <inherited>true/falseinherited>    <configuration>configuration>execution>                        executions>                        <dependencies><dependency>dependency>                        dependencies>                        <goals>goals>                        <inherited>true/falseinherited>                        <configuration>configuration>                    plugin>                plugins>            build>                        <modules>                                <module>module>            modules>                        <repositories>                                <repository>                    <releases>                        <enabled><enabled>                        <updatePolicy>updatePolicy>                        <checksumPolicy>checksumPolicy>                    releases>                    <snapshots>                        <enabled><enabled>                        <updatePolicy>updatePolicy>                        <checksumPolicy>checksumPolicy>                    snapshots>                    <id>id>                    <name>name>                    <url>url>                    <layout>layout>                repository>            repositories>                        <pluginRepositories>                                <pluginRepository>                    <releases>                        <enabled><enabled>                        <updatePolicy>updatePolicy>                        <checksumPolicy>checksumPolicy>                    releases>                    <snapshots>                        <enabled><enabled>                        <updatePolicy>updatePolicy>                        <checksumPolicy>checksumPolicy>                    snapshots>                    <id>id>                    <name>name>                    <url>url>                    <layout>layout>                pluginRepository>            pluginRepositories>                        <dependencies>                                <dependency>                dependency>            dependencies>                        <reports>reports>                        <reporting>reporting>                        <dependencyManagement>                <dependencies>                                        <dependency>                    dependency>                dependencies>            dependencyManagement>                        <distributionManagement>            distributionManagement>                        <properties />        profile>    profiles>        <modules>                <module>module>    modules>        <repositories>                <repository>                        <releases>                                <enabled><enabled>                                <updatePolicy>updatePolicy>                                <checksumPolicy>checksumPolicy>            releases>                        <snapshots>                <enabled><enabled>                <updatePolicy>updatePolicy>                <checksumPolicy>checksumPolicy>            snapshots>                        <id> banseon-repository-proxy id>                        <name> banseon-repository-proxy name>                        <url> http://192.168.1.169:9999/repository/ url>                        <layout> default layout>        repository>    repositories>        <pluginRepositories>                <pluginRepository>        pluginRepository>    pluginRepositories>        <dependencies>        <dependency>                        <groupId> org.apache.maven groupId>                        <artifactId> maven-artifact artifactId>                        <version> 3.8.1 version>                        <type> jar type>                        <classifier>classifier>                        <scope> test scope>                        <systemPath>systemPath>                        <exclusions>                <exclusion>                    <artifactId> spring-core artifactId>                    <groupId> org.springframework groupId>                exclusion>            exclusions>                        <optional> true optional>        dependency>    dependencies>        <reports>reports>        <reporting>                <excludeDefaults />                <outputDirectory />                <plugins>                        <plugin>                                <groupId>groupId>                                <artifactId>artifactId>                                <version>version>                                <inherited>true/falseinherited>                                <configuration>configuration>                                <reportSets>                                        <reportSet>                                                <id>id>                                                <configuration>configuration>                                                <inherited>true/falseinherited>                                                <reports>reports>                    reportSet>                reportSets>            plugin>        plugins>    reporting>        <dependencyManagement>        <dependencies>                        <dependency>            dependency>        dependencies>    dependencyManagement>        <distributionManagement>                <repository>                        <uniqueVersion />            <id> banseon-maven2 id>            <name> banseon maven2 name>            <url> file://${basedir}/target/deploy url>            <layout>layout>        repository>                <snapshotRepository>            <uniqueVersion />            <id> banseon-maven2 id>            <name> Banseon-maven2 Snapshot Repository name>            <url> scp://svn.baidu.com/banseon:/usr/local/maven-snapshot url>            <layout>layout>        snapshotRepository>                <site>                        <id> banseon-site id>                        <name> business api website name>                        <url>                scp://svn.baidu.com/banseon:/var/www/localhost/banseon-web            url>        site>                <downloadUrl />                <relocation>                        <groupId>groupId>                        <artifactId>artifactId>                        <version>version>                        <message>message>        relocation>                <status>status>    distributionManagement>        <properties>        <name>valuename>    properties>project> 
//例如<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">        <modelVersion>4.0.0modelVersion>    <groupId>com.qhgroupId>    <artifactId>mavenartifactId>    <version>1.0-SNAPSHOTversion>    <packaging>warpackaging>        <properties>        <maven.compiler.source>19maven.compiler.source>        <maven.compiler.target>19maven.compiler.target>        <project.build.sourceEncoding>UTF-8project.build.sourceEncoding>    properties>        <dependencies>        <dependency>            <groupId>junitgroupId>            <artifactId>junitartifactId>            <version>4.13.2version>            <scope>testscope>        dependency>    dependencies>    <build>        <plugins>            <plugin>                <groupId>org.apache.tomcat.mavengroupId>                <artifactId>tomcat7-maven-pluginartifactId>                <version>2.2version>                <configuration>                    <port>80port>                    <path>/path>                configuration>            plugin>        plugins>    build>    project>

来源地址:https://blog.csdn.net/qq_43699122/article/details/128537162

阅读原文内容投诉

免责声明:

① 本站未注明“稿件来源”的信息均来自网络整理。其文字、图片和音视频稿件的所属权归原作者所有。本站收集整理出于非商业性的教育和科研之目的,并不意味着本站赞同其观点或证实其内容的真实性。仅作为临时的测试数据,供内部测试之用。本站并未授权任何人以任何方式主动获取本站任何信息。

② 本站未注明“稿件来源”的临时测试数据将在测试完成后最终做删除处理。有问题或投稿请发送至: 邮箱/279061341@qq.com QQ/279061341

软考中级精品资料免费领

  • 历年真题答案解析
  • 备考技巧名师总结
  • 高频考点精准押题
  • 2024年上半年信息系统项目管理师第二批次真题及答案解析(完整版)

    难度     813人已做
    查看
  • 【考后总结】2024年5月26日信息系统项目管理师第2批次考情分析

    难度     354人已做
    查看
  • 【考后总结】2024年5月25日信息系统项目管理师第1批次考情分析

    难度     318人已做
    查看
  • 2024年上半年软考高项第一、二批次真题考点汇总(完整版)

    难度     435人已做
    查看
  • 2024年上半年系统架构设计师考试综合知识真题

    难度     224人已做
    查看

相关文章

发现更多好内容

猜你喜欢

AI推送时光机
位置:首页-资讯-后端开发
咦!没有更多了?去看看其它编程学习网 内容吧
首页课程
资料下载
问答资讯