标签:dispatch services webapp oss enabled top 不同的 post com
相同的jar在不同的项目中保存了多份
下载链接: https://maven.apache.org/docs/history.html
下载apache-maven-3.5.4-bin.zip (适用于Windows系统), 然后解压
有如下目录
系统环境变量下:
测试
<localRepository>D:\Program Files\Maven_shine\repository_shine</localRepository>
<!-- 选择一个磁盘目录, 作为本地仓库 -->
<!-- 在已有的profiles标签中添加profile标签 -->
<profile>
<id>jdk-1.8</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>
<!-- 让增加的profile生效 -->
<activeProfiles>
<activeProfile>jdk-1.5</activeProfile>
</activeProfiles>
当需要依赖时, 会从仓库中查找, 优先顺序为
本地仓库>私服(如果配置了的话)>公共仓库(如果配置了的话)>中央仓库
<!-- 在mirror标签下添加mirror标签 -->
<mirror>
<id>aliyun</id>
<!-- 中心仓库的mirror 镜像 -->
<mirrorOf>central</mirrorOf>
<name>Nexus aliyun</name>
<!-- aliyun仓库地址 以后所有要指向中心仓库的请求 都会指向aliyun仓库 -->
<url>https://maven.aliyun.com/nexus/content/groups/public</url>
</mirror>
因为现在阿里云不支持http访问, 支持https, 所以有SSL证书验证的问题
[重要]所以还需要在IDEA中添加一个配置
在Maven下的Importing的VM options for importer下导入
<?xml version="1.0" encoding="UTF-8"?>
<!--pom: project object model-->
<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.dz</groupId>
<artifactId>MavenProject</artifactId>
<version>1.0-SNAPSHOT</version>
<!--打包方式 如果是java项目则用jar
如果是web项目则用war-->
<!--<packaging>jar</packaging>-->
<packaging>war</packaging>
</project>
<properties>
<!--编译编码-->
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<packaging>war</packaging>
<properties>
<!--编译编码-->
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<!--定义项目中需要的所有依赖-->
<dependencies>
<!-- https://mvnrepository.com/artifact/javax.servlet/jstl -->
<dependency>
<!--jstl支持-->
<groupId>javax.servlet</groupId>
<artifactId>jstl</artifactId>
<version>1.2</version>
</dependency>
</dependencies>
<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.dz</groupId>
<artifactId>MavenProject</artifactId>
<version>1.0-SNAPSHOT</version>
<!--打包方式 如果是java项目则用jar
如果是web项目则用war-->
<!--<packaging>jar</packaging>-->
<packaging>war</packaging>
</project>
<?xml version="1.0" encoding="UTF-8"?>
<!--pom: project object model-->
<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.dz</groupId>
<artifactId>MavenProject</artifactId>
<version>1.0-SNAPSHOT</version>
<!--打包方式 如果是java项目则用jar
如果是web项目则用war-->
<!--<packaging>jar</packaging>-->
<packaging>war</packaging>
<properties>
<!--编译编码-->
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<!--定义项目中需要的所有依赖-->
<dependencies>
<!--web 项目的编译环境-->
<!-- https://mvnrepository.com/artifact/javax.servlet/jstl -->
<dependency>
<!--jstl支持-->
<groupId>javax.servlet</groupId>
<artifactId>jstl</artifactId>
<version>1.2</version>
</dependency>
<!-- https://mvnrepository.com/artifact/javax.servlet/javax.servlet-api -->
<dependency>
<!--servlet编译环境-->
<groupId>javax.servlet</groupId>
<artifactId>javax.servlet-api</artifactId>
<version>3.1.0</version>
<scope>provided</scope>
</dependency>
<!-- https://mvnrepository.com/artifact/javax.servlet/jsp-api -->
<dependency>
<!--jsp编译环境-->
<groupId>javax.servlet</groupId>
<artifactId>jsp-api</artifactId>
<version>2.0</version>
<scope>provided</scope>
</dependency>
<!-- https://mvnrepository.com/artifact/mysql/mysql-connector-java -->
</dependencies>
</project>
<?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_3_1.xsd"
version="3.1">
</web-app>
package com.dz.servlet;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
@WebServlet(name = "TestServlet", value = "/test")
public class TestServlet extends HttpServlet {
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
System.out.println("Test Servlet!");
request.getRequestDispatcher("/index.jsp").forward(request,response);
}
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
doPost(request,response);
}
}
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
<title>Title</title>
</head>
<body>
<span style="color: red">Hello World!</span>
</body>
</html>
<dependencies>
<dependency>
<!--jstl支持-->
<groupId>javax.servlet</groupId>
<artifactId>jstl</artifactId>
<version>1.2</version>
</dependency>
<dependency>
<!--servlet编译环境-->
<groupId>javax.servlet</groupId>
<artifactId>javax.servlet-api</artifactId>
<version>3.1.0</version>
<!--生命周期-->
<scope>provided</scope>
</dependency>
<dependency>
<!--jsp编译环境-->
<groupId>javax.servlet</groupId>
<artifactId>jsp-api</artifactId>
<version>2.0</version>
<!--生命周期-->
<scope>provided</scope>
</dependency>
</dependencies>
<servers>
<!-- 设置私库认证信息(访问) -->
<server>
<id>nexus-public</id>
<username>admin</username>
<password>admin123</password>
</server>
</servers>
<mirrors>
<mirror>
<!-- 设置代理镜像 -->
<id>huaweicloud</id>
<!-- 为Central中央仓库设置华为云镜像 -->
<mirrorOf>Central</mirrorOf>
<name>Nexus huaweicloud</name>
<!-- 华为仓库地址 以后所有要指向中心仓库的请求 都会指向华为仓库 -->
<url>https://mirrors.huaweicloud.com/repository/maven/</url>
</mirror>
</mirrors>
<profiles>
<!-- 设置私服地址(仓库组) -->
<profile>
<id>nexus</id>
<repositories>
<repository>
<!-- nexus的认证id -->
<id>nexus-public</id>
<!-- name随便 -->
<name>Naxus Release Snapshot Repository</name>
<!-- nexus中仓库组对应的地址 -->
<url>http://localhost:8081/nexus/content/groups/public/</url>
<releases><enabled>true</enabled></releases>
<snapshots><enabled>true</enabled></snapshots>
</repository>
</repositories>
<!-- 插件仓库地址, 各节点的含义和上面是一样的 -->
<pluginRepositories>
<pluginRepository>
<!-- nexus的认证id -->
<id>nexus-public</id>
<!-- nexus中仓库组对应的地址 -->
<url>http://localhost:8081/nexus/content/groups/public/</url>
<releases><enabled>true</enabled></releases>
<snapshots><enabled>true</enabled></snapshots>
</pluginRepository>
</pluginRepositories>
<profile>
</profiles>
<!-- 激活nexus -->
<activeProfiles>
<activeProfile>nexus</activeProfile>
</activeProfiles>
<!-- 在项目的pom.xml中 配置私服的仓库地址, 可以将项目打jar包部署到私服-->
<distributionManagement>
<snapshotRepository>
<id>nexus-public</id><!-- nexus的认证id -->
<name>User Project Snapshot</name>
<!-- Snapshots仓库地址-->
<url>http://localhost:8081/nexus/content/repositories/snapshots/</url>
<uniqueVersion>true</uniqueVersion>
</snapshotRepository>
<repository>
<id>nexus-public</id><!-- nexus的认证id -->
<name>User Project Release</name>
<!-- Releases仓库地址-->
<url>http://localhost:8081/nexus/content/repositories/releases/</url>
</repository>
</distributionManagement>
标签:dispatch services webapp oss enabled top 不同的 post com
原文地址:https://www.cnblogs.com/MRASdoubleZ/p/14720076.html