• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

pdurbin/maven-hello-world: simple, minimal Maven example: hello world

原作者: [db:作者] 来自: 网络 收藏 邀请

开源软件名称(OpenSource Name):

pdurbin/maven-hello-world

开源软件地址(OpenSource Url):

https://github.com/pdurbin/maven-hello-world

开源编程语言(OpenSource Language):

Java 100.0%

开源软件介绍(OpenSource Introduction):

A simple, minimal Maven example: hello world

To create the files in this git repo we've already run mvn archetype:generate from http://maven.apache.org/guides/getting-started/maven-in-five-minutes.html

mvn archetype:generate -DgroupId=com.mycompany.app -DartifactId=my-app -DarchetypeArtifactId=maven-archetype-quickstart -DinteractiveMode=false

Now, to print "Hello World!", type either...

cd my-app
mvn compile
java -cp target/classes com.mycompany.app.App

or...

cd my-app
mvn package
java -cp target/my-app-1.0-SNAPSHOT.jar com.mycompany.app.App

Running mvn clean will get us back to only the source Java and the pom.xml:

murphy:my-app pdurbin$ mvn clean --quiet
murphy:my-app pdurbin$ ack -a -f
pom.xml
src/main/java/com/mycompany/app/App.java
src/test/java/com/mycompany/app/AppTest.java

Running mvn compile produces a class file:

murphy:my-app pdurbin$ mvn compile --quiet
murphy:my-app pdurbin$ ack -a -f
pom.xml
src/main/java/com/mycompany/app/App.java
src/test/java/com/mycompany/app/AppTest.java
target/classes/com/mycompany/app/App.class
murphy:my-app pdurbin$ 
murphy:my-app pdurbin$ java -cp target/classes com.mycompany.app.App
Hello World!

Running mvn package does a compile and creates the target directory, including a jar:

murphy:my-app pdurbin$ mvn clean --quiet
murphy:my-app pdurbin$ mvn package > /dev/null
murphy:my-app pdurbin$ ack -a -f
pom.xml
src/main/java/com/mycompany/app/App.java
src/test/java/com/mycompany/app/AppTest.java
target/classes/com/mycompany/app/App.class
target/maven-archiver/pom.properties
target/my-app-1.0-SNAPSHOT.jar
target/surefire-reports/com.mycompany.app.AppTest.txt
target/surefire-reports/TEST-com.mycompany.app.AppTest.xml
target/test-classes/com/mycompany/app/AppTest.class
murphy:my-app pdurbin$ 
murphy:my-app pdurbin$ java -cp target/my-app-1.0-SNAPSHOT.jar com.mycompany.app.App
Hello World!

Running mvn clean compile exec:java requires http://mojo.codehaus.org/exec-maven-plugin/

Running java -jar target/my-app-1.0-SNAPSHOT.jar requires http://maven.apache.org/plugins/maven-shade-plugin/




鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
krasa/MavenHelper: IntelliJ plugin - https://plugins.jetbrains.com/plugin/7179发布时间:2022-08-16
下一篇:
selenium-saikrishna/maven发布时间:2022-08-16
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap