首页
关于
壁纸
直播
留言
友链
统计
Search
1
《三国志英杰传》攻略
6,034 阅读
2
Emby客户端IOS破解
5,767 阅读
3
白嫖Emby
5,764 阅读
4
《吞食天地1》金手指代码
4,691 阅读
5
破解emby-server
4,039 阅读
moonjerx
game
age-of-empires
zx3
san-guo-zhi
尼尔:机械纪元
net
emby
learn-video
docker
torrent
photoshop
route
minio
git
ffmpeg
im
vue
gitlab
typecho
svn
alipay
nasm
srs
mail-server
tailscale
kkfileview
aria2
webdav
synology
redis
oray
chemical
mxsite
math
π
x-ui
digital-currency
server
nginx
baota
k8s
http
cloud
linux
shell
database
vpn
esxi
rancher
domain
k3s
ewomail
os
android
windows
ios
app-store
macos
develop
java
javascript
uniapp
nodejs
hbuildx
maven
android-studio
jetbrain
jenkins
css
mybatis
php
python
hardware
hard-disk
pc
RAM
software
pt
calibre
notion
office
language
literature
philosophy
travel
登录
Search
标签搜索
ubuntu
mysql
openwrt
zerotier
springboot
centos
openvpn
jdk
吞食天地2
synology
spring
idea
windows11
吞食天地1
transmission
google-play
Japanese
xcode
群晖
kiftd
MoonjerX
累计撰写
370
篇文章
累计收到
459
条评论
首页
栏目
moonjerx
game
age-of-empires
zx3
san-guo-zhi
尼尔:机械纪元
net
emby
learn-video
docker
torrent
photoshop
route
minio
git
ffmpeg
im
vue
gitlab
typecho
svn
alipay
nasm
srs
mail-server
tailscale
kkfileview
aria2
webdav
synology
redis
oray
chemical
mxsite
math
π
x-ui
digital-currency
server
nginx
baota
k8s
http
cloud
linux
shell
database
vpn
esxi
rancher
domain
k3s
ewomail
os
android
windows
ios
app-store
macos
develop
java
javascript
uniapp
nodejs
hbuildx
maven
android-studio
jetbrain
jenkins
css
mybatis
php
python
hardware
hard-disk
pc
RAM
software
pt
calibre
notion
office
language
literature
philosophy
travel
页面
关于
壁纸
直播
留言
友链
统计
搜索到
7
篇与
maven
的结果
2023-01-07
解决maven出现“连接到http://repo.maven.apache.org被拒绝”的问题
1、原因这个问题的原因就是无法连接到http://repo.maven.apache.org/maven2镜像2、解决办法修改maven默认镜像仓库地址为国内可用的镜像地址,比如这里推荐阿里的镜像仓库地址http://maven.aliyun.com/nexus/content/groups/public/该镜像仓库地址亲测可用,而且速度极快,强烈推荐3、操作步骤1、找到你IDEA配置的maven位置
2023年01月07日
148 阅读
0 评论
0 点赞
2023-01-03
修改idea的maven3远程镜像仓库地址settings.xml
1.找到idea安装目录中maven3插件位置以我自己的安装目录为例: D:\Program Files\JetBrains\IntelliJ IDEA 2020.3\plugins\maven\lib\maven3\conf 修改 settings.xml 文件,原文件几乎没有任何配置。2.修改镜像仓库远程地址在 mirrors 标签中加入以下部分,配置私有镜像仓库地址。可以在私有镜像仓库缓存中央仓库jar包,可以加速本地下载jar包速度。<mirror> <id>maven-public</id> <mirrorOf>*</mirrorOf> <name>maven-public</name> <url>http://192.168.2.199:8080/repository/maven-public/</url> <blocked>true</blocked> </mirror>中央仓库<mirror> <id>maven-public</id> <mirrorOf>*</mirrorOf> <name>maven-public</name> <url>https://repo1.maven.org/maven2/</url> <blocked>true</blocked> </mirror>阿里镜像仓库<mirror> <id>public</id> <mirrorOf>*</mirrorOf> <name>aliyun nexus</name> <url>http://maven.aliyun.com/nexus/content/groups/public/</url> <blocked>true</blocked> </mirror>或<mirror> <id>mirror-aliyun-releases</id> <mirrorOf>*</mirrorOf> <name>aliyun maven mirror</name> <url>https://maven.aliyun.com/repository/public</url> <blocked>true</blocked> </mirror><?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> --> <!-- 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>maven-public</id> <mirrorOf>*</mirrorOf> <name>maven-public</name> <url>http://192.168.2.199:8080/repository/maven-public/</url> <blocked>true</blocked> </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> --> </profiles> <!-- activeProfiles | List of profiles that are active for all builds. | <activeProfiles> <activeProfile>alwaysActiveProfile</activeProfile> <activeProfile>anotherAlwaysActiveProfile</activeProfile> </activeProfiles> --> </settings>3.也可以直接在pom.xml修改镜像仓库远程地址<repositories> <repository> <id>maven-public</id> <name>maven-public</name> <url>http://192.168.2.199:8080/repository/maven-public/</url> <releases> <enabled>true</enabled> </releases> </repository> <repository> <id>public</id> <name>aliyun nexus</name> <url>http://maven.aliyun.com/nexus/content/groups/public/</url> <releases> <enabled>true</enabled> </releases> </repository> </repositories> <pluginRepositories> <pluginRepository> <id>maven-public</id> <name>maven-public</name> <url>http://192.168.2.199:8080/repository/maven-public/</url> <releases> <enabled>true</enabled> </releases> <snapshots> <enabled>false</enabled> </snapshots> </pluginRepository> <pluginRepository> <id>public</id> <name>aliyun nexus</name> <url>http://maven.aliyun.com/nexus/content/groups/public/</url> <releases> <enabled>true</enabled> </releases> <snapshots> <enabled>false</enabled> </snapshots> </pluginRepository> </pluginRepositories>
2023年01月03日
70 阅读
0 评论
0 点赞
2022-12-13
maven学习<dependencyManagement>正确使用方法
一、介绍 Maven中的dependencyManagement元素提供了一种管理依赖版本号的方式。在dependencyManagement元素中声明所依赖的jar包的版本号等信息,那么所有子项目再次引入此依赖jar包时则无需显式的列出版本号。Maven会沿着父子层级向上寻找拥有dependencyManagement 元素的项目,然后使用它指定的版本号。二、使用步骤创建以父依赖:<?xml version="1.0" encoding="UTF-8"?> <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.0</modelVersion> <groupId>com.yan</groupId> <artifactId>springcloud1</artifactId> <version>1.0-SNAPSHOT</version> <modules> <module>springcloud-api</module> <module>springcloud-provider-dept--8001</module> <module>springcloud-consumer-dept-80</module> <module>springcloud-eureka-7001</module> <module>springcloud-eureka-7002</module> <module>springcolud-eureka-7003</module> <module>springcloud-provider-dept--8002</module> <module>springcloud-provider-dept--8003</module> <module>springcloud-consumer-dept-feign</module> <module>springcloud-provider-dept-hystrix-8002</module> <module>springcloud-consumer-hystrix-dashboard</module> <module>springcloud-zuul-9527</module> <module>springcloud-config-server-3344</module> </modules> <!--打包方式pom--> <packaging>pom</packaging> <properties> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> <maven.compiler.source>1.8</maven.compiler.source> <maven.compiler.target>1.8</maven.compiler.target> <junit.version>4.12</junit.version> <lombok.version>1.16.10</lombok.version> <log4j.version>1.2.17</log4j.version> </properties> <!-- 这里进行版本管理,模块需要用到什么需要自己去导--> <dependencyManagement> <dependencies> <!-- 导入springCloud依赖--> <dependency> <groupId>org.springframework.cloud</groupId> <artifactId>spring-cloud-dependencies</artifactId> <version>Greenwich.SR1</version> <type>pom</type> <scope>import</scope> </dependency> <!-- springBoot--> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-dependencies</artifactId> <version>2.1.4.RELEASE</version> <type>pom</type> <scope>import</scope> </dependency> <!-- 连接数据库--> <dependency> <groupId>mysql</groupId> <artifactId>mysql-connector-java</artifactId> <version>5.1.47</version> </dependency> <dependency> <groupId>com.alibaba</groupId> <artifactId>druid</artifactId> <version>1.1.10</version> </dependency> <!-- springBoot mybatis启动器--> <dependency> <groupId>org.mybatis.spring.boot</groupId> <artifactId>mybatis-spring-boot-starter</artifactId> <version>1.3.2</version> </dependency> <!-- 日志测试--> <!-- junit--> <dependency> <groupId>junit</groupId> <artifactId>junit</artifactId> <version>${junit.version}</version> </dependency> <!-- lombok--> <dependency> <groupId>org.projectlombok</groupId> <artifactId>lombok</artifactId> <version>${lombok.version}</version> </dependency> <!-- log4j--> <dependency> <groupId>log4j</groupId> <artifactId>log4j</artifactId> <version>${log4j.version}</version> </dependency> <dependency> <groupId>ch.qos.logback</groupId> <artifactId>logback-core</artifactId> <version>1.2.3</version> </dependency> </dependencies> </dependencyManagement> <build> </build> </project> 这里module就是使用到的子模块,他们都收到父模块的版本控制,但是依赖需要自己去导入,properties里面就是版本的一个控制,然后dependencyManagement里面就可以放我们的父依赖了总结 如果有多个子项目都引用同一样依赖,则可以避免在每个使用的子项目里都声明一个版本号。当想升级或切换到另一个版本时,只需要在顶层父容器里更新,而不需要逐个修改子项目;另外如果某个子项目需要另外的一个版本,只需要声明version即可。dependencyManagement中定义的只是依赖的声明,并不实现引入,因此子项目需要显式的声明需要用的依赖。
2022年12月13日
81 阅读
0 评论
0 点赞
2022-12-13
docker搭建maven私有仓库
(一)引言在实际开发工作中,通常需要搭建maven私有仓库。(二)Nexus介绍 Nexus 是Maven仓库管理器,如果你使用Maven,你可以从Maven中央仓库 下载所需要的构件(artifact),但这通常不是一个好的做法,你应该在本地架设一个Maven仓库服务器,在代理远程仓库的同时维护本地仓库,以节省带宽和时间,Nexus就可以满足这样的需要。此外,他还提供了强大的仓库管理功能,构件搜索功能,它基于REST,友好的UI是一个extjs的REST客户端,它占用较少的内存,基于简单文件系统而非数据库。这些优点使其日趋成为最流行的Maven仓库管理器。(三)安装docker请参考 Docker安装_Icoolkj的博客(四)docker中安装nexus31、拉取镜像## 通过docker search nexus 命令搜索一下docker公有库在的 nexus相关的镜像 [root@icoolkj ~]# docker search nexus## 拉取nexus3镜像 [root@icoolkj /]# docker pull sonatype/nexus3 Using default tag: latest latest: Pulling from sonatype/nexus3 f70d60810c69: Pull complete 545277d80005: Pull complete 10b49635409a: Pull complete Digest: sha256:3fd7e90bcf49fb55d87d852cab854e5669ed115b09bdb25f47c45ee0797231aa 147.6MB/295.3MB Status: Downloaded newer image for sonatype/nexus3:latest docker.io/sonatype/nexus3:latest [root@icoolkj /]# 2、建立数据储存文件夹## 建立数据存放文件夹,用于docker中nexus的数据与本地物理机映射 [root@icoolkj /]# mkdir -p /usr/local/nexus3/nexus-data [root@icoolkj /]# ll /usr/local/nexus3/ 总用量 4 drwxr-xr-x 2 root root 4096 6月 3 18:06 nexus-data ## 更改权限 [root@icoolkj /]# chmod 777 /usr/local/nexus3/nexus-data/ [root@icoolkj /]# ll /usr/local/nexus3/ 总用量 4 drwxr-xr-x 2 777 root 4096 6月 3 18:06 nexus-data [root@icoolkj /]# 3、安装并运行容器## 编写启动脚本docker-nexus3-start.sh docker rm -f docker-nexus3 || true docker run --name docker-nexus3 \ -p 8081:8081 \ -v /usr/local/nexus3/nexus-data:/nexus-data \ --restart=always \ -d sonatype/nexus3 ## 参数说明 --name nexus #启动该容器的名字,可以自己更改为自己想要的名字 -p 8081:8081 #端口映射,将本地8081端口映射为容器的8081端口,第一个8081可以改成自己想要放开的端口 -v /docker/nexus/nexus-data:/nexus-data # 将容器的/nexus-data地址 代理到 本地/docker/nexus/nexus-data文件夹下 --restart=always #在重启docker时,自动重启改容器。 -d sonatype/nexus3 #即为后台运行一直sonatype/nexus34、获取容器的日志[root@icoolkj nexus3]# docker logs -f --tail 20 docker-nexus3(五)使用nexus31、浏览器访问2、配置Nexus提示输入密码,并告知你的密码储存位置Your admin user password is located in /nexus-data/admin.password on the server.因为docker中nexus3的数据储存位置与本地物理机建立了映射关系,所有在物理机上的地址应该是/usr/local/nexus3/nexus-data/admin.password登录成功后需要更改密码,更改密码需要记住(浏览器都有记住密码的功能,顺⼿点保存⾯,下次你直接登录就好了);更改密码完成之后,admin.password⽂件⾃动删除!!!## 默认仓库说明 maven-central:maven中央库,默认从https://repo1.maven.org/maven2/拉取jar maven-releases:私库发行版jar,初次安装请将Deployment policy设置为Allow redeploy maven-snapshots:私库快照(调试版本)jar maven-public:仓库分组,把上面三个仓库组合在一起对外提供服务,在本地maven基础配置settings.xml或项目pom.xml中使用## Nexus仓库类型介绍 hosted:本地仓库,通常我们会部署自己的构件到这一类型的仓库。比如公司的第二方库。 proxy:代理仓库,它们被用来代理远程的公共仓库,如maven中央仓库。 group:仓库组,用来合并多个hosted/proxy仓库,当你的项目希望在多个repository使用资源时就不需要多次引用了,只需要引用一个group即可。如图所示,代理仓库负责代理远程中央仓库,托管仓库负责本地资源,组资源库 = 代理资源库 + 托管资源库3、配置阿里云代理仓库1)、新建仓库(Create repository)Repository-->Repositories-->Create repository-->maven2(proxy)填写仓库名称——maven-aliyun,并填入仓库urlhttps://maven.aliyun.com/repository/public2)、配置仓库组(默认已有一个maven-public) 注:注意仓库顺序。maven查找依赖时会依次遍历仓库组中的仓库。## 官方文档中建议: It is recommended practice to place hosted repositories higher in the list than proxy repositories. For proxy repositories, the repository manager needs to check the remote repository which will incur more overhead than a hosted repository lookup. 希望将hosted repositories【托管资源库】的顺序放在proxy repositories【代理资源库】之前,因为一个group【组资源库】中可以涵括这些托管资源库和代理资源库。而一整个的group是作为一个public,一个接口给别人使用的。所以当查找架包的时候,如果代理资源库在前面,那就是先从远程去查找jar,而不是先从托管资源库(本地仓库)去查找是否有jar。这样访问外网的消耗比起来在本地查找,当然是将托管资源库放在代理资源库之前的优先位置了。4、创建角色创建角色(develop),并分配nx-all权限Security-->Roles-->Create注:创建角色的同时可以为当前创建的角色分配权限。5、创建用户创建用户(developer),并授予develop角色Security-->Users-->Create注:创建用户并为创建的用户挂上相应的角色。(六)maven配置文件Maven下的setting.xml文件和项目中的pom.xml文件的关系是:settting.xml文件是全局设置,而pom.xml文件是局部设置。pom.xml文件对于项目来说,是优先使用的。而pom.xml文件中如果没有配置镜像地址的话,就按照settting.xml中定义的地址去查找。修改本地maven配置文件(conf/setting.xml)servers节点下添加以下内容(username和password为刚刚在nexus3中添加的用户和其密码) <!--nexus服务器,id为组仓库name--> <servers> <server> <id>maven-public</id> <username>developer</username> <password>icoolkj</password> </server> <server> <id>maven-releases</id> <!--对应pom.xml的id=releases的仓库--> <username>developer</username> <password>icoolkj</password> </server> <server> <id>maven-snapshots</id> <!--对应pom.xml中id=snapshots的仓库--> <username>developer</username> <password>icoolkj</password> </server> </servers>mirrors节点下添加以下内容 <!--仓库组的url地址,id和name可以写组仓库name,mirrorOf的值设置为central--> <mirrors> <mirror> <id>maven-public</id> <name>maven-public</name> <!--镜像采用配置好的组的地址--> <url>http://182.92.199.85:8081/repository/maven-public/</url> <mirrorOf>central</mirrorOf> </mirror> </mirrors>(七)项目中发布pom.xml配置实际使用中distributionManagement可以配置在parent项目中,子项目无需重复配置。上述配置全部完成后就可以在项目中使用mven clean deploy将项目的jar包上传到自己的私服上了。 <repositories> <repository> <id>maven-public</id> <name>Nexus Repository</name> <url>http://192.168.1.188:8081/repository/maven-public/</url> <snapshots> <enabled>true</enabled> </snapshots> <releases> <enabled>true</enabled> </releases> </repository> </repositories> <pluginRepositories> <pluginRepository> <id>maven-public</id> <name>Nexus Plugin Repository</name> <url>http://192.168.1.188:8081/repository/maven-public/</url> <snapshots> <enabled>true</enabled> </snapshots> <releases> <enabled>true</enabled> </releases> </pluginRepository> </pluginRepositories> <!--项目分发信息,在执行mvn deploy后表示要发布的位置。有了这些信息就可以把网站部署到远程服务器或者把构件jar等部署到远程仓库。 --> <distributionManagement> <repository><!--部署项目产生的构件到远程仓库需要的信息 --> <id>maven-releases</id><!-- 此处id和settings.xml的id保持一致 --> <name>Nexus Release Repository</name> <url>http://192.168.1.188:8081/repository/maven-releases/</url> </repository> <snapshotRepository><!--构件的快照部署到哪里?如果没有配置该元素,默认部署到repository元素配置的仓库,参见distributionManagement/repository元素 --> <id>maven-snapshots</id><!-- 此处id和settings.xml的id保持一致 --> <name>Nexus Snapshot Repository</name> <url>http://192.168.1.188:8081/repository/maven-snapshots/</url> </snapshotRepository> </distributionManagement>至此,nexus搭建完毕,支持本地部署依赖jar包。
2022年12月13日
162 阅读
0 评论
0 点赞
2022-12-05
Ubuntu下Maven安装和使用
一、安装Maven安装Maven之前,必须安装了 JDK ,参考 JDK安装1.1 首先下载Maven的压缩包下载 apache-maven-3.8.8-bin.tar.gz1.2 解压到HOME目录tar zxvf apache-maven-3.8.8-bin.tar.gz -C ~1.3 在/etc/profile下添加环境变量编辑环境变量:sudo vi /etc/profile增加maven的HOME目录export M2_HOME=/home/gzx/apache-maven-3.8.8将Maven的bin目录添加到path路径PATH=$M2_HOME/bin:$PATH1.4 重载环境变量配置source /etc/profile1.5 验证环境变量是否存在echo $M2_HOMEecho $PATH1.6 验证Maven配置是否成功mvn -v1.7 修改本地仓库不修改配置的话,下载的文件都会保存到本地仓库 ~/.m2/repositoryMaven 中。这里指定本地仓库为 /home/gzx/Documents/Program/maven_localRepository 在文件 $M2_HOME/conf/settings.xml的localRepositor y的开头添加一行:<localRepository>/home/gzx/Documents/Program/maven_localRepository</localRepository>1.8 更改Maven的中央仓库为aliyun,提高下载jar的速度在 $M2_HOME/conf/settings.xml 下添加如下内容:<mirrors> <mirror> <id>alimaven</id> <name>aliyun maven</name> <url>https://maven.aliyun.com/repository/public</url> <mirrorOf>central</mirrorOf> </mirror> </mirrors>二、用Maven生成Java项目2.1 生成Java SE项目运行命令:mvn archetype:generate -DgroupId=com.baobao -DartifactId=javase 一路默认即可。注意是generate命令,而不是create命令。这样将在test目录下生成一个javase的目录,有测试目录和源码目录,同时生成相应的com/bao的java类包。这样的目录是Maven默认生成的,如下:可以看到javase的根目录下有一个pom.xml的配置文件,这个文件是Maven的核心文件,指定了依赖的jar包、源码的编码、打包方式等。<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"> <!-- Maven的版本 --> <modelVersion>4.0.0</modelVersion> <!-- 下面三个是本项目区别于其他项目的坐标 --> <groupId>com.baobao</groupId> <artifactId>javase</artifactId> <version>1.0-SNAPSHOT</version> <!-- 打包成jar格式 --> <packaging>jar</packaging> <name>javase</name> <url>http://maven.apache.org</url> <!-- 源码的编码方式为UTF-8 --> <properties> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> </properties> <!-- 声明本项目依赖的jar包 --> <dependencies> <dependency> <!-- 单元测试jar包,scope指定只在测试目录起作用 --> <groupId>junit</groupId> <artifactId>junit</artifactId> <version>3.8.1</version> <scope>test</scope> </dependency> </dependencies> </project>2.2 生成Java Web项目运行命令:mvn archetype:generate -DgroupId=com.baobao -DartifactId=javaee -DarchetypeArtifactId=maven-archetype-webapp这样将产生默认目录的web项目2.3 Maven的默认目录目录用途src/main/javaApplication/Library sourcessrc/main/resourcesApplication/Library resourcessrc/main/filtersResource filter filessrc/main/assemblyAssembly descriptorssrc/main/configConfiguration filessrc/main/scriptsApplication/Library scriptssrc/main/webappWeb application sourcessrc/test/javaTest sourcessrc/test/resourcesTest resourcessrc/test/filtersTest resource filter filessrc/siteSiteLICENSE.txtProject’s licenseNOTICE.txtNotices and attributions required by libraries that the project depends onREADME.txtProject’s readme三、Maven常用命令#清除target目录 mvn clean #编译: mvn compile #运行 mvn exec:java -Dexec.mainClass="主类全名" -Dexec.args="传递的参数" #跳过测试打包 mvn package -DskipTests #测试 mvn test #打包 mvn package #下载当前项目依赖的jar包的源码 mvn dependency:sources #下载当前项目依赖的jar包的文档 mvn dependency:resolve -Dclassifier=javadoc #安装jar包到本地仓库 mvn install #安装jar源码到本地仓库 mvn source:jar install #安装jar doc到本地仓库 mvn javadoc:jar install #上传jar包到本地仓库和私服 mvn deploy #安装某个目录下的pom到本地仓库 mvn install:install-file -DgroupId=a.tc -DartifactId=tcdev -Dversion=init-SNAPSHOT -Dpackaging=pom -Dfile=tcdev-init-SNAPSHOT.pom转载自:https://blog.csdn.net/ac_dao_di/article/details/54233520
2022年12月05日
175 阅读
0 评论
0 点赞
1
2
您的IP: