<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/maven-v4_0_0.xsd"> <modelVersion>4.0.0</modelVersion> <groupId>net.biancheng.www</groupId> <artifactId>helloMaven</artifactId> <packaging>jar</packaging> <version>1.0-SNAPSHOT</version> <name>helloMaven</name> <url>http://maven.apache.org</url> <dependencies> <dependency> <groupId>junit</groupId> <artifactId>junit</artifactId> <version>3.8.1</version> <scope>test</scope> </dependency> </dependencies> </project>
mvn clean package
[INFO] Scanning for projects... [INFO] [INFO] --------------------< net.biancheng.www:helloMaven >-------------------- [INFO] Building helloMaven 1.0-SNAPSHOT [INFO] --------------------------------[ jar ]--------------------------------- [INFO] [INFO] --- maven-clean-plugin:2.5:clean (default-clean) @ helloMaven --- [INFO] Deleting D:\maven\helloMaven\target [INFO] [INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ helloMaven --- [WARNING] Using platform encoding (GBK actually) to copy filtered resources, i.e. build is platform dependent! [INFO] skip non existing resourceDirectory D:\maven\helloMaven\src\main\resources [INFO] [INFO] --- maven-compiler-plugin:3.1:compile (default-compile) @ helloMaven --- [INFO] Changes detected - recompiling the module! [WARNING] File encoding has not been set, using platform encoding GBK, i.e. build is platform dependent! [INFO] Compiling 1 source file to D:\maven\helloMaven\target\classes [INFO] [INFO] --- maven-resources-plugin:2.6:testResources (default-testResources) @ helloMaven --- [WARNING] Using platform encoding (GBK actually) to copy filtered resources, i.e. build is platform dependent! [INFO] skip non existing resourceDirectory D:\maven\helloMaven\src\test\resources [INFO] [INFO] --- maven-compiler-plugin:3.1:testCompile (default-testCompile) @ helloMaven --- [INFO] Changes detected - recompiling the module! [WARNING] File encoding has not been set, using platform encoding GBK, i.e. build is platform dependent! [INFO] Compiling 1 source file to D:\maven\helloMaven\target\test-classes [INFO] [INFO] --- maven-surefire-plugin:2.12.4:test (default-test) @ helloMaven --- [INFO] Surefire report directory: D:\maven\helloMaven\target\surefire-reports Downloading from central: https://repo.maven.apache.org/maven2/org/apache/maven/surefire/surefire-junit3/2.12.4/surefire-junit3-2.12.4.pom Downloaded from central: https://repo.maven.apache.org/maven2/org/apache/maven/surefire/surefire-junit3/2.12.4/surefire-junit3-2.12.4.pom (1.7 kB at 1.3 kB/s) Downloading from central: https://repo.maven.apache.org/maven2/org/apache/maven/surefire/surefire-junit3/2.12.4/surefire-junit3-2.12.4.jar Downloaded from central: https://repo.maven.apache.org/maven2/org/apache/maven/surefire/surefire-junit3/2.12.4/surefire-junit3-2.12.4.jar (26 kB at 51 kB/s) ------------------------------------------------------- T E S T S ------------------------------------------------------- Running net.biancheng.www.AppTest Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.007 sec Results : Tests run: 1, Failures: 0, Errors: 0, Skipped: 0 [INFO] [INFO] --- maven-jar-plugin:2.4:jar (default-jar) @ helloMaven --- [INFO] Building jar: D:\maven\helloMaven\target\helloMaven-1.0-SNAPSHOT.jar [INFO] ------------------------------------------------------------------------ [INFO] BUILD SUCCESS [INFO] ------------------------------------------------------------------------ [INFO] Total time: 4.775 s [INFO] Finished at: 2021-03-02T17:20:15+08:00 [INFO] ------------------------------------------------------------------------
图1:target 目录
说明:
java net.biancheng.www.App
Hello World!
package net.biancheng.www; /** * Maven 项目中添加的自定义java类 * * @author 编程帮 www.lmcjl.com */ public class Util { public static void printMessage(String message) { System.out.println(message); } }
package net.biancheng.www; /** * @author 编程帮 www.lmcjl.com */ public class App { public static void main(String[] args) { Util.printMessage("编程帮欢迎您,网址:www.lmcjl.com"); } }
mvn clean compile
[INFO] Scanning for projects... [INFO] [INFO] --------------------< net.biancheng.www:helloMaven >-------------------- [INFO] Building helloMaven 1.0-SNAPSHOT [INFO] --------------------------------[ jar ]--------------------------------- [INFO] [INFO] --- maven-clean-plugin:2.5:clean (default-clean) @ helloMaven --- [INFO] Deleting D:\maven\helloMaven\target [INFO] [INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ helloMaven --- [WARNING] Using platform encoding (GBK actually) to copy filtered resources, i.e. build is platform dependent! [INFO] skip non existing resourceDirectory D:\maven\helloMaven\src\main\resources [INFO] [INFO] --- maven-compiler-plugin:3.1:compile (default-compile) @ helloMaven --- [INFO] Changes detected - recompiling the module! [WARNING] File encoding has not been set, using platform encoding GBK, i.e. build is platform dependent! [INFO] Compiling 2 source files to D:\maven\helloMaven\target\classes [INFO] ------------------------------------------------------------------------ [INFO] BUILD SUCCESS [INFO] ------------------------------------------------------------------------ [INFO] Total time: 0.853 s [INFO] Finished at: 2021-03-03T09:26:29+08:00 [INFO] ------------------------------------------------------------------------
java net.biancheng.www.App
编程帮欢迎您,网址:www.lmcjl.com
本文链接:http://task.lmcjl.com/news/15439.html