上传项目到maven中央仓库所需配置

pom.xml

<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>cn.takujo</groupId>
	<artifactId>common-api</artifactId>
	<version>1.0.0</version>
	<packaging>jar</packaging>

	<name>common-api</name>
	<url>https://gitee.com/takujo_admin/common-api</url>
	<description>takujoframework common-api</description>

	<licenses>
		<license>
			<name>The Apache Software License, Version 2.0</name>
			<url>http://www.apache.org/licenses/LICENSE-2.0.txt</url>
		</license>
	</licenses>

	<developers>
		<developer>
			<name>takujo</name>
			<email>@qq.com</email>
		</developer>
	</developers>

	<scm>
		<connection>
	        scm:git:https://gitee.com/takujo_admin/common-api.git
	    </connection>
		<developerConnection>
	        scm:git:https://gitee.com/takujo_admin/common-api.git
	    </developerConnection>
		<url>https://gitee.com/takujo_admin/common-api</url>
	</scm>

	<properties>
		<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
	</properties>

	<dependencies>
		<dependency>
			<groupId>junit</groupId>
			<artifactId>junit</artifactId>
			<version>4.12</version>
			<scope>test</scope>
		</dependency>
	</dependencies>

	<profiles>
		<profile>
			<id>release</id>
			<build>
				<plugins>
					<plugin>
						<groupId>org.sonatype.plugins</groupId>
						<artifactId>nexus-staging-maven-plugin</artifactId>
						<version>1.6.7</version>
						<extensions>true</extensions>
						<configuration>
							<serverId>服务器id(在settings.xml中)</serverId>
							<nexusUrl>https://oss.sonatype.org/</nexusUrl>
						</configuration>
					</plugin>
					<plugin>
						<groupId>org.apache.maven.plugins</groupId>
						<artifactId>maven-source-plugin</artifactId>
						<version>3.0.1</version>
						<executions>
							<execution>
								<id>attach-sources</id>
								<phase>package</phase>
								<goals>
									<goal>jar</goal>
								</goals>
							</execution>
						</executions>
					</plugin>
					<plugin>
						<groupId>org.apache.maven.plugins</groupId>
						<artifactId>maven-javadoc-plugin</artifactId>
						<version>2.10.4</version>
						<configuration>
							<encoding>UTF-8</encoding>
							<charset>UTF-8</charset>
							<docencoding>UTF-8</docencoding>
						</configuration>
						<executions>
							<execution>
								<id>attach-javadocs</id>
								<phase>package</phase>
								<goals>
									<goal>jar</goal>
								</goals>
							</execution>
						</executions>
					</plugin>
					<plugin>
						<groupId>org.apache.maven.plugins</groupId>
						<artifactId>maven-gpg-plugin</artifactId>
                        <version>1.6</version>
						<executions>
							<execution>
								<phase>verify</phase>
								<goals>
									<goal>sign</goal>
								</goals>
							</execution>
						</executions>
					</plugin>
					<plugin>
						<artifactId>maven-compiler-plugin</artifactId>
						<version>3.5.1</version>
						<configuration>
							<source>1.8</source>
							<target>1.8</target>
						</configuration>
					</plugin>
				</plugins>
			</build>
			<distributionManagement>
				<snapshotRepository>
					<id>服务器id(在settings.xml中)</id>
					<url>https://oss.sonatype.org/content/repositories/snapshots/</url>
				</snapshotRepository>
				<repository>
					<id>服务器id(在settings.xml中)</id>
		         <url>https://oss.sonatype.org/service/local/staging/deploy/maven2/</url>
				</repository>
			</distributionManagement>
		</profile>
	</profiles>
</project>

maven conf文件夹中settings.xml加入服务器配置

<server>
      <id>自定义标识id(在pom.xml中引用)</id>
      <username>(https://issues.sonatype.org/ 网站注册的用户名)</username>
      <password>(https://issues.sonatype.org/ 网站注册的密码)</password>
</server>

最后登录https://oss.sonatype.org/进行管理

发布了35 篇原创文章 · 获赞 3 · 访问量 1万+

猜你喜欢

转载自blog.csdn.net/takujo/article/details/83591597