Maven项目打包jar到私服
来源:互联网 发布:电视机怎么看网络电视 编辑:程序博客网 时间:2024/06/05 06:59
工具:IntelliJ IDEA、Maven
前提 已经有私服地址(这里假设为 http://192.168.1.112:8081/nexus/),并且maven已经做好相关的配置
maven中settings.xml的配置如下:
<?xml version="1.0" encoding="UTF-8"?><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>D:\repo</localRepository> <mirrors> <mirror> <id>MyCentral</id> <name>nexus</name> <url>http://192.168.1.112:8081/nexus/content/repositories/central/</url> <mirrorOf>central</mirrorOf> </mirror> </mirrors> <profiles> <profile> <id>MyCentral</id> <repositories> <repository> <id>Mythirdparty</id> <name>SmartCentury thirdparty repository</name> <url>http://192.168.1.112:8081/nexus/content/repositories/thirdparty/</url> </repository> <repository> <id>My-Central</id> <name>SmartCentury central repository</name> <url>http://192.168.1.112:8081/nexus/content/repositories/central/</url> <releases><enabled>true</enabled></releases> <snapshots><enabled>true</enabled></snapshots> </repository> <repository> <id>nexus-releases</id> <name>nexus-releases</name> <url>http://192.168.1.112:8081/nexus/content/repositories/releases/</url> </repository> <repository> <id>nexus-snapshot</id> <name>nexus-snapshot</name> <url>http://192.168.1.112:8081/nexus/content/repositories/snapshots/</url> </repository> </repositories> <pluginRepositories> <pluginRepository> <id>MyPlugin</id> <name>Nexus</name> <url>>http://192.168.1.112:8081/nexus/content/repositories/central/</url> <releases><enabled>true</enabled></releases> <snapshots><enabled>true</enabled></snapshots> </pluginRepository> </pluginRepositories> </profile> </profiles> <activeProfiles> <activeProfile>MyCentral</activeProfile> </activeProfiles></settings>
1、在Maven中settings.xml配置文件中的servers节点中配置如下:
<servers> <server> <id>nexus-snapshot</id> <username>admin</username> <password>admin123</password> </server> <server> <id>nexus-release</id> <username>admin</username> <password>admin123</password> </server></servers>
2、在要打包到私服的maven项目的pom.xml文件中,添加如下配置:
<build> <plugins> <plugin> <artifactId>maven-source-plugin</artifactId> <version>2.2.1</version> <executions> <execution> <id>attach-sources</id> <phase>verify</phase> <goals> <goal>jar-no-fork</goal> </goals> </execution> </executions> </plugin> </plugins> </build> <distributionManagement> <repository> <id>nexus-releases</id> <name>Packaging Release Repository</name> <url>http://192.168.1.209:8081/nexus/content/repositories/releases/</url> </repository> <snapshotRepository> <id>nexus-snapshot</id> <name>Packaging Snapshot Repository</name> <url>http://192.168.1.209:8081/nexus/content/repositories/snapshots/</url> </snapshotRepository> </distributionManagement>
注:这里的id与settings文件中server的id相对应;maven-source-plugin是为了将源代码可以打包打私服上。
3、如果没有maven,则全部要在pom.xml中配置。还要配置相关的maven plugin
<properties> <file_encoding>UTF-8</file_encoding> <project.build.sourceEncoding>${file_encoding}</project.build.sourceEncoding> <java_source_version>1.7</java_source_version> <java_target_version>1.7</java_target_version> <!-- maven插件 --> <maven_clean_plugin_version>2.5</maven_clean_plugin_version> <maven_resources_plugin_version>2.6</maven_resources_plugin_version> <maven_compiler_plugin_version>3.1</maven_compiler_plugin_version> <maven_source_plugin_version>3.0.1</maven_source_plugin_version> <maven_jar_plugin_version>2.3.2</maven_jar_plugin_version> <maven_war_plugin_version>2.1.1</maven_war_plugin_version> <maven_install_plugin_version>2.5.1</maven_install_plugin_version> <maven_deploy_plugin_version>2.7</maven_deploy_plugin_version> <maven_surefire_plugin_version>2.17</maven_surefire_plugin_version> </properties> <build> <pluginManagement> <plugins> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-clean-plugin</artifactId> <version>${maven_clean_plugin_version}</version> </plugin> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-resources-plugin</artifactId> <version>${maven_resources_plugin_version}</version> <configuration> <encoding>${file_encoding}</encoding> </configuration> </plugin> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-compiler-plugin</artifactId> <version>${maven_compiler_plugin_version}</version> <configuration> <fork>true</fork> <source>${java_source_version}</source> <target>${java_target_version}</target> <encoding>${file_encoding}</encoding> </configuration> </plugin> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-source-plugin</artifactId> <version>${maven_source_plugin_version}</version> <executions> <execution> <id>attach-sources</id> <phase>package</phase> <goals> <goal>jar-no-fork</goal> </goals> </execution> </executions> </plugin> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-jar-plugin</artifactId> <version>${maven_jar_plugin_version}</version> <configuration> <archive> <addMavenDescriptor>true</addMavenDescriptor> <index>true</index> <manifest> <addDefaultSpecificationEntries>true</addDefaultSpecificationEntries> <addDefaultImplementationEntries>true</addDefaultImplementationEntries> </manifest> </archive> </configuration> </plugin> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-war-plugin</artifactId> <version>${maven_war_plugin_version}</version> </plugin> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-install-plugin</artifactId> <version>${maven_install_plugin_version}</version> </plugin> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-deploy-plugin</artifactId> <version>${maven_deploy_plugin_version}</version> </plugin> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-surefire-plugin</artifactId> <version>${maven_surefire_plugin_version}</version> </plugin> </plugins> </pluginManagement> <plugins> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-deploy-plugin</artifactId> <configuration> <skip>false</skip> </configuration> </plugin> </plugins> </build> <repositories> <repository> <id>nexus-releases</id> <name>nexus-releases</name> <url>http://192.168.1.112:8081/nexus/content/repositories/releases/</url> <releases><enabled>true</enabled></releases> </repository> <repository> <id>nexus-snapshot</id> <name>nexus-snapshot</name> <url>http://192.168.1.112:8081/nexus/content/repositories/snapshots/</url> <snapshots><enabled>true</enabled></snapshots> </repository> </repositories> <!-- 部署到nexus私服上的配置 --> <distributionManagement> <repository> <id>nexus-releases</id> <name>nexus-releases</name> <url>http://192.168.1.112:8081/nexus/content/repositories/releases/</url> </repository> <snapshotRepository> <id>nexus-snapshot</id> <name>nexus-snapshot</name> <url>http://192.168.1.112:8081/nexus/content/repositories/snapshots/</url> </snapshotRepository> </distributionManagement>
4、输入 mvn deploy 命令,即可将jar包和source文件一并上传到私服上。
0 0
- Maven项目打包jar到私服
- maven项目打包成jar
- 将maven项目打包为可执行jar
- Maven项目打包成可执行Jar文件
- Maven项目打包成可执行的jar
- Maven项目打包成可执行Jar文件
- Maven项目打包成可执行Jar文件
- maven项目打包依赖的jar包
- maven项目打包成可执行的jar
- maven 打包jar,可以运行项目
- Maven 项目打包成可执行Jar文件
- Maven 项目打包源文件 *-sources.jar
- MAVEN项目打包成jar,供普通Java项目调用
- maven 打包可执行jar
- maven打包本地jar
- Maven: Jar打包
- Maven打包jar
- maven打包jar
- 使用ThinkAndroid数据库及解决造成ANR问题
- 【java开发系列】—— 自定义注解
- RecyclerView使用初体验
- 矩阵——P1962 斐波那契数列
- 支持向量机学习
- Maven项目打包jar到私服
- thinkphp中如何访问我们自定义的扩展目录?
- Android Imageview控制它的宽高比例属性详解
- String,Date,Calendar之间的转换,转自String Date Calendar之间的转换
- js页面跳转
- Windows 下面pip 使用阿里源
- Spring AOP 之 Aspect
- python初级教程:入门详解
- Android 打包