java maven 读写pdf_Maven文档实战(IDEA)

本文介绍了使用maven生成可执行的jar包的方法,分享给大家,具体如下:

从pom的xsi中可以打开描述pom的schema:

可以看到pom中,project的结构:

默认的mvn install生成的jar是不带主类入口的,需要在maven-compile-plugin中设置主类,

xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">

4.0.0

com.cetc.di

hellocetc

0.0.1-SNAPSHOT

jar

hellocetc

http://maven.apache.org

UTF-8

junit

junit

3.8.1

test

org.apache.maven.plugins

maven-jar-plugin

1.8

1.8

com.cetc.di.hellocetc.App

true

lib/

执行mvn install:

在target目录中,发现jar包已经生成:

用java decompiler,可以看到manifest中已经加入了MainClass:

使用mvn help:effective-pom可以看到pom.xml的完整结构(包括继承而来的属性):

[INFO] Scanning for projects...

[INFO]

[INFO] ------------------------------------------------------------------------

[INFO] Building hellocetc 0.0.1-SNAPSHOT

[INFO] ------------------------------------------------------------------------

[INFO]

[INFO] --- maven-help-plugin:2.2:effective-pom (default-cli) @ hellocetc ---

[INFO]

Effective POMs, after inheritance, interpolation, and profiles are applied:

4.0.0

com.cetc.di

hellocetc

0.0.1-SNAPSHOT

hellocetc

http://maven.apache.org

UTF-8

junit

junit

3.8.1

test

false

central

Central Repository

https://repo.maven.apache.org/maven2

never

false

central

Central Repository

https://repo.maven.apache.org/maven2

D:\Users\a\Workspaces\MyEclipse 2015\hellocetc\src\main\java

D:\Users\a\Workspaces\MyEclipse 2015\hellocetc\src\main\scripts

D:\Users\a\Workspaces\MyEclipse 2015\hellocetc\src\test\java

D:\Users\a\Workspaces\MyEclipse 2015\hellocetc\target\classes

D:\Users\a\Workspaces\MyEclipse 2015\hellocetc\target\test-classes

D:\Users\a\Workspaces\MyEclipse 2015\hellocetc\src\main\resources

D:\Users\a\Workspaces\MyEclipse 2015\hellocetc\src\test\resources

D:\Users\a\Workspaces\MyEclipse 2015\hellocetc\target

hellocetc-0.0.1-SNAPSHOT

maven-antrun-plugin

1.3

maven-assembly-plugin

2.2-beta-5

maven-dependency-plugin

2.8

maven-release-plugin

2.3.2

maven-jar-plugin

2.4

1.8

1.8

com.cetc.di.hellocetc.App

true

lib/

maven-clean-plugin

2.5

default-clean

clean

clean

maven-resources-plugin

2.6

default-testResources

process-test-resources

testResources

default-resources

process-resources

resources

maven-jar-plugin

2.4

default-jar

package

jar

1.8

1.8

com.cetc.di.hellocetc.App

true

lib/

1.8

1.8

com.cetc.di.hellocetc.App

true

lib/

maven-compiler-plugin

3.1

default-compile

compile

compile

default-testCompile

test-compile

testCompile

maven-surefire-plugin

2.12.4

default-test

test

test

maven-install-plugin

2.4

default-install

install

install

maven-deploy-plugin

2.7

default-deploy

deploy

deploy

maven-site-plugin

3.3

default-site

site

site

D:\Users\a\Workspaces\MyEclipse 2015\hellocetc\target\site

org.apache.maven.plugins

maven-project-info-reports-plugin

default-deploy

site-deploy

deploy

D:\Users\a\Workspaces\MyEclipse 2015\hellocetc\target\site

org.apache.maven.plugins

maven-project-info-reports-plugin

D:\Users\a\Workspaces\MyEclipse 2015\hellocetc\target\site

org.apache.maven.plugins

maven-project-info-reports-plugin

D:\Users\a\Workspaces\MyEclipse 2015\hellocetc\target\site

[INFO] ------------------------------------------------------------------------

[INFO] BUILD SUCCESS

[INFO] ------------------------------------------------------------------------

[INFO] Total time: 0.526 s

[INFO] Finished at: 2015-11-18T20:05:12+08:00

[INFO] Final Memory: 10M/245M

[INFO] ------------------------------------------------------------------------

以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持码农之家。

已被852人点赞

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值