接上一篇maven3.5.2配置
例题:maven项目1.0版本上传到nexus私服里我自己定义的myRelease里面
 
一、新建项目,选择Maven

- setting选好
3. 这个GroupId、(Version我改成了1.0了)和上面上传成功的文件对应 已经构建好的如下 4.有颜色和图标:右键Make Directory as就可以改颜色,方便看,test里面是测试的,main里面是程序
 5. 刚刚新建的test2  6. 什么都没有,在main目录下添加webapp–>WEB-INF和web.xml 7. web.xml文件代码在最后面 8. 最后来改pom.xml 9. 重点就是导入依赖,从点击下载依赖这个网站下载,复制的代码复制到pom.xml文件的<dependencies></dependencies>里面 10. 复制了以后会有提示 10.
- 点击Enable Auto-import就可以了
- 以后会自动下载
- 还有一个重点是nexus私服部署项目,在pom.xml的<project>里面添加如下代码
<distributionManagement>
<repository>
<id>nexus-shine</id>
<url>http://localhost:8081/nexus/repository/myRelease/</url>
</repository>
<snapshotRepository>
<id>nexus-shine</id>
<url>http://localhost:8081/nexus/repository/mySnapshot/</url>
</snapshotRepository>
</distributionManagement>
- id和上一篇setting.xml里面的配置要一致
- url是直接复制的我的mySnapshot和myRelease
- 最后双击deploy就可以了
以下是pom.xml代码,看注释
<?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>org.example</groupId>
<artifactId>test</artifactId>
<version>1.0</version>
<packaging>war</packaging>
<dependencies>
<dependency>
<groupId>commons-io</groupId>
<artifactId>commons-io</artifactId>
<version>2.11.0</version>
</dependency>
<dependency>
<groupId>javax.servlet.jsp.jstl</groupId>
<artifactId>jstl</artifactId>
<version>1.2</version>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>javax.servlet-api</artifactId>
<version>3.1.0</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>jsp-api</artifactId>
<version>2.0</version>
<scope>provided</scope>
</dependency>
</dependencies>
<distributionManagement>
<repository>
<id>nexus-shine</id>
<url>http://localhost:8081/nexus/repository/myRelease/</url>
</repository>
<snapshotRepository>
<id>nexus-shine</id>
<url>http://localhost:8081/nexus/repository/mySnapshot/</url>
</snapshotRepository>
</distributionManagement>
</project>
web.xml代码
<?xml version="1.0" encoding="utf-8" ?>
<web-app xmlns="http://xmlns.jcp.org/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_4_0.xsd"
version="4.0">
</web-app>
|