maven打包指定lib路径,修改manifest

指定自定义的lib路径,把lib一起打包到jar包中,需要修改compiler插件的定义。

需要注意的是,如果pom中已经有一个 maven-compiler-plugin定义了,就直接添加属性就行了,而不要额外复制一个,同时存在2个配置的话,有一个会不生效。

 <plugin>
          <artifactId>maven-compiler-plugin</artifactId>
          <version>3.7.0</version>
          <configuration>
	          <source>1.8</source>
	          <target>1.8</target>
	          <compilerArguments>
	               <extdirs>lib(这里填写的是lib的路径,因为我的lib是在项目根目录下的,所以就直接写了lib)</extdirs>
	          </compilerArguments>
          </configuration>
</plugin>

修改manifest属性,需要修改jar插件的配置

<plugin>
                    <artifactId>maven-jar-plugin</artifactId>
                    <version>3.0.2</version>
                    <configuration>
                        <archive>
                            <manifest>
                                <addClasspath>true</addClasspath>
                            </manifest>
                            <manifestEntries>
                                <Premain-Class>com.runtime.bytecode.UdAgent</Premain-Class>
                            </manifestEntries>

                        </archive>
                    </configuration>
                </plugin>

猜你喜欢

转载自blog.csdn.net/ljz2016/article/details/84135286