尝试建立新项目上传,分享
D:devworkspacehelloworld>tree /F 卷 DATAPART 的文件夹 PATH 列表 卷序列号为 2C22-0A1A D:. │ pom.xml │ └─src └─main └─java └─helloworld Xiaoming.java
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.zno</groupId> <artifactId>helloworld</artifactId> <version>0.0.1-SNAPSHOT</version> <repositories> <repository> <id>nexus</id> <name>nexus</name> <url>http://192.168.0.244:8081/nexus/content/groups/public/</url> <releases> <enabled>true</enabled> </releases> <snapshots> <enabled>true</enabled> </snapshots> </repository> </repositories> <pluginRepositories> <pluginRepository> <id>nexus</id> <name>nexus</name> <url>http://192.168.0.244:8081/nexus/content/groups/public/</url> <releases> <enabled>true</enabled> </releases> <snapshots> <enabled>true</enabled> </snapshots> </pluginRepository> </pluginRepositories> <distributionManagement> <repository> <id>user-releases</id> <name>user-releases</name> <url>http://192.168.0.244:8081/nexus/content/repositories/releases/</url> </repository> <snapshotRepository> <id>user-snapshots</id> <name>user-snapshots</name> <url>http://192.168.0.244:8081/nexus/content/repositories/snapshots/</url> </snapshotRepository> </distributionManagement> </project>
Xiaoming.java
package helloworld; public class Xiaoming { public void say(){ System.out.println("Hello World!"); } }
部署
D:devworkspacehelloworld>mvn clean deploy [INFO] Scanning for projects... [INFO] [INFO] ------------------------------------------------------------------------ [INFO] Building helloworld 0.0.1-SNAPSHOT [INFO] ------------------------------------------------------------------------ [INFO] [INFO] --- maven-clean-plugin:2.4.1:clean (default-clean) @ helloworld --- [INFO] Deleting D:devworkspacehelloworld arget [INFO] [INFO] --- maven-resources-plugin:2.5:resources (default-resources) @ helloworld --- [debug] execute contextualize [WARNING] Using platform encoding (GBK actually) to copy filtered resources, i.e . build is platform dependent! [INFO] Copying 0 resource [INFO] [INFO] --- maven-compiler-plugin:2.3.2:compile (default-compile) @ helloworld -- - [WARNING] File encoding has not been set, using platform encoding GBK, i.e. buil d is platform dependent! [INFO] Compiling 1 source file to D:devworkspacehelloworld argetclasses [INFO] [INFO] --- maven-resources-plugin:2.5:testResources (default-testResources) @ he lloworld --- [debug] execute contextualize [WARNING] Using platform encoding (GBK actually) to copy filtered resources, i.e . build is platform dependent! [INFO] Copying 0 resource [INFO] [INFO] --- maven-compiler-plugin:2.3.2:testCompile (default-testCompile) @ hello world --- [INFO] Nothing to compile - all classes are up to date [INFO] [INFO] --- maven-surefire-plugin:2.10:test (default-test) @ helloworld --- [INFO] Surefire report directory: D:devworkspacehelloworld argetsurefire-re ports Downloading: http://192.168.0.244:8081/nexus/content/groups/public/org/apache/ma ven/surefire/surefire-junit3/2.10/surefire-junit3-2.10.pom Downloaded: http://192.168.0.244:8081/nexus/content/groups/public/org/apache/mav en/surefire/surefire-junit3/2.10/surefire-junit3-2.10.pom (0 B at 0.0 KB/sec) Downloading: http://192.168.0.244:8081/nexus/content/groups/public/org/apache/ma ven/surefire/surefire-junit3/2.10/surefire-junit3-2.10.jar Downloaded: http://192.168.0.244:8081/nexus/content/groups/public/org/apache/mav en/surefire/surefire-junit3/2.10/surefire-junit3-2.10.jar (0 B at 0.0 KB/sec) ------------------------------------------------------- T E S T S ------------------------------------------------------- Results : Tests run: 0, Failures: 0, Errors: 0, Skipped: 0 [INFO] [INFO] --- maven-jar-plugin:2.3.2:jar (default-jar) @ helloworld --- [INFO] Building jar: D:devworkspacehelloworld argethelloworld-0.0.1-SNAPSHO T.jar [INFO] [INFO] --- maven-install-plugin:2.3.1:install (default-install) @ helloworld --- [INFO] Installing D:devworkspacehelloworld argethelloworld-0.0.1-SNAPSHOT.j ar to C:UsersAdministrator.m2 epositorycnznohelloworld .0.1-SNAPSHOThel loworld-0.0.1-SNAPSHOT.jar [INFO] Installing D:devworkspacehelloworldpom.xml to C:UsersAdministrator .m2 epositorycnznohelloworld .0.1-SNAPSHOThelloworld-0.0.1-SNAPSHOT.pom [INFO] [INFO] --- maven-deploy-plugin:2.7:deploy (default-deploy) @ helloworld --- Downloading: http://192.168.0.244:8081/nexus/content/repositories/snapshots/cn/z no/helloworld/0.0.1-SNAPSHOT/maven-metadata.xml Uploading: http://192.168.0.244:8081/nexus/content/repositories/snapshots/cn/zno /helloworld/0.0.1-SNAPSHOT/helloworld-0.0.1-20160315.095232-1.jar Uploaded: http://192.168.0.244:8081/nexus/content/repositories/snapshots/cn/zno/ helloworld/0.0.1-SNAPSHOT/helloworld-0.0.1-20160315.095232-1.jar (3 KB at 16.0 K B/sec) Uploading: http://192.168.0.244:8081/nexus/content/repositories/snapshots/cn/zno /helloworld/0.0.1-SNAPSHOT/helloworld-0.0.1-20160315.095232-1.pom Uploaded: http://192.168.0.244:8081/nexus/content/repositories/snapshots/cn/zno/ helloworld/0.0.1-SNAPSHOT/helloworld-0.0.1-20160315.095232-1.pom (2 KB at 16.9 K B/sec) Downloading: http://192.168.0.244:8081/nexus/content/repositories/snapshots/cn/z no/helloworld/maven-metadata.xml Uploading: http://192.168.0.244:8081/nexus/content/repositories/snapshots/cn/zno /helloworld/0.0.1-SNAPSHOT/maven-metadata.xml Uploaded: http://192.168.0.244:8081/nexus/content/repositories/snapshots/cn/zno/ helloworld/0.0.1-SNAPSHOT/maven-metadata.xml (766 B at 8.8 KB/sec) Uploading: http://192.168.0.244:8081/nexus/content/repositories/snapshots/cn/zno /helloworld/maven-metadata.xml Uploaded: http://192.168.0.244:8081/nexus/content/repositories/snapshots/cn/zno/ helloworld/maven-metadata.xml (276 B at 3.2 KB/sec) [INFO] ------------------------------------------------------------------------ [INFO] BUILD SUCCESS [INFO] ------------------------------------------------------------------------ [INFO] Total time: 6.079s [INFO] Finished at: Tue Mar 15 17:52:32 GMT+08:00 2016 [INFO] Final Memory: 14M/154M [INFO] ------------------------------------------------------------------------
二、使用组件
点击搜索,然后
找到了,】
<dependency> <groupId>cn.zno</groupId> <artifactId>helloworld</artifactId> <version>0.0.1-SNAPSHOT</version> </dependency>
就像使用 http://mvnrepository.com/ 一样,爽!