<plugins> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-compiler-plugin</artifactId> <version>3.2</version> <configuration> <source>1.7</source> <target>1.7</target> <showWarnings>true</showWarnings> </configuration> </plugin> <!--打入jar包的jar <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-shade-plugin</artifactId> <version>1.4</version> <configuration> <createDependencyReducedPom>true</createDependencyReducedPom> </configuration> <executions> <execution> <phase>package</phase> <goals> <goal>shade</goal> </goals> <configuration> <transformers> <transformer implementation="org.apache.maven.plugins.shade.resource.DontIncludeResourceTransformer"> <resource>META-INF/ECLIPSEF.SF</resource> </transformer> <transformer implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer"> <mainClass>com.zeus.plug.HttpServerMain</mainClass> </transformer> </transformers> </configuration> </execution> </executions> </plugin> --> <!-- 把依赖jar打另外文件夹 --> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-dependency-plugin</artifactId> <version>2.8</version> <executions> <execution> <id>copy-lib</id> <phase>package</phase> <goals> <goal>copy-dependencies</goal> </goals> <configuration> <excludeScope>test</excludeScope> <excludeScope>provided</excludeScope> <outputDirectory>${basedir}/target/lib</outputDirectory> </configuration> </execution> <execution> <id>copy-modules</id> <phase>package</phase> <goals> <goal>copy</goal> </goals> <configuration> <artifactItems> <artifactItem> <groupId>${project.groupId}</groupId> <artifactId>${project.artifactId}</artifactId> <version>${project.version}</version> <type>jar</type> <overWrite>true</overWrite> <outputDirectory>${basedir}/target/lib</outputDirectory> </artifactItem> </artifactItems> </configuration> </execution> </executions> </plugin> </plugins>
启动依赖jar的java jar包
java -cp ./lib;zeus-plug-0.0.1-SNAPSHOT.jar com.zeus.plug.HttpServerMain
java -Dport=8089 -cp ./lib;zeus-plug-0.0.1-SNAPSHOT.jar com.zeus.plug.HttpServerMain
---启动jar
java -jar ****.jar
---指定端口启动jar
java -jar -Dport=8089 *****.jar
时间: 2024-11-06 12:07:18