1 Star 0 Fork 0

zheng108 / org

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
贡献代码
同步代码
取消
提示: 由于 Git 不支持空文件夾,创建文件夹后会生成空的 .keep 文件
Loading...
README
MIT

mvn

项目介绍

可执行jar

原理

maven-assembly-plugin 将依赖的jar打包至jar内lib下

java -jar *.jar,通过读取jar包内/META-INF/MANIFEST.MF,将jar包内的依赖包复制至./lib,类加载器会自动加载

配置

pom.xml

mvn package中执行assembly打包(按src.xml配置)

<plugin>
	<groupId>org.apache.maven.plugins</groupId>
	<artifactId>maven-assembly-plugin</artifactId>
	<version>3.1.0</version>
	<configuration>
		<archive>
			<manifest>
				<mainClass>${project.groupId}.App</mainClass>
				<addClasspath>true</addClasspath>
				<classpathPrefix>${project.lib}</classpathPrefix>
			</manifest>
		</archive>
		<descriptors>
			<descriptor>src/main/assembly/src.xml</descriptor>
		</descriptors>
	</configuration>
	<executions>
		<execution>
			<phase>package</phase>
			<goals>
				<goal>single</goal>
			</goals>
		</execution>
	</executions>
</plugin>

src.xml

<assembly
	xmlns="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.0"
	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
	xsi:schemaLocation="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.0 http://maven.apache.org/xsd/assembly-1.1.0.xsd">
	<id>bin</id>
	<formats>
		<format>jar</format>
	</formats>
	<includeBaseDirectory>false</includeBaseDirectory>
	<dependencySets>
		<dependencySet>
			<unpack>false</unpack>
			<scope>runtime</scope>
			<excludes>
				<exclude>${project.groupId}:${project.artifactId}</exclude>
			</excludes>
			<outputDirectory>${project.lib}</outputDirectory>
		</dependencySet>
	</dependencySets>
	<fileSets>
		<fileSet>
			<directory>${project.build.directory}/classes</directory>
			<outputDirectory>/</outputDirectory>
		</fileSet>
		<fileSet>
			<directory>${project.build.directory}/classes</directory>
			<outputDirectory>/WEB-INF/classes</outputDirectory>
		</fileSet>
		<fileSet>
			<directory>/src</directory>
			<outputDirectory>/src</outputDirectory>
		</fileSet>
	</fileSets>
</assembly>

使用说明

mvn help:system

mvn archetype:generate -X -DarchetypeCatalog=local

mvn test

mvn package -Dmaven.test.skip=true  
java -jar  mvn-1.0-SNAPSHOT-bin.jar
java -jar  mvn-1.0-SNAPSHOT-bin.jar 8000
java -jar  mvn-1.0-SNAPSHOT-bin.jar 8080 ssms.war
The MIT License (MIT) Copyright (c) 2018 zheng108 Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

简介

暂无描述 展开 收起
Java
MIT
取消

发行版

暂无发行版

贡献者

全部

近期动态

加载更多
不能加载更多了
Java
1
https://gitee.com/cike/org.git
git@gitee.com:cike/org.git
cike
org
org
war

搜索帮助