MAVEN does not add dependent jar packages by default, so it is not possible to mvn clean install packages directly if you want to run a standalone jar package. Need to change the pom file slightly, add the following plugin
<Build> <sourcedirectory>Src/main/java</sourcedirectory> <Plugins> <plugin> <groupId>Org.apache.maven.plugins</groupId> <Artifactid>Maven-compiler-plugin</Artifactid> <Configuration> <Defaultlibbundledir>Lib</Defaultlibbundledir> <Source>1.5</Source> <Target>1.5</Target> <encoding>UTF-8</encoding> </Configuration> </plugin> <plugin> <groupId>Org.apache.maven.plugins</groupId> <Artifactid>Maven-jar-plugin</Artifactid> <Configuration> <Archive> <Manifest> <Addclasspath>True</Addclasspath> <Classpathprefix></Classpathprefix> <MainClass>com.xx.xx.xx</MainClass> </Manifest> </Archive> </Configuration> </plugin> <plugin> <groupId>Org.apache.maven.plugins</groupId> <Artifactid>Maven-dependency-plugin</Artifactid> <executions> <Execution> <ID>Copy</ID> <Phase>Install</Phase> <Goals> <goal>Copy-dependencies</goal> </Goals> <Configuration> <outputdirectory>${project.build.directory}</outputdirectory> </Configuration> </Execution> </executions> </plugin> <plugin> <groupId>Org.apache.maven.plugins</groupId> <Artifactid>Maven-resources-plugin</Artifactid> <version>2.2</version> <Configuration> <encoding>UTF-8</encoding> </Configuration> </plugin> </Plugins> </Build>
Some jar packages are not mavencenter when MAVEN is packaged. The relevant local jar package needs to be introduced in the POM, then the relevant depency should be changed as follows
<Dependency> <groupId>Org.wltea.ik-analyzer</groupId> <Artifactid>Ik-analyzer</Artifactid> <version>3.2.8</version> <Scope>System</Scope> <Systempath>${project.basedir}/lib/ik-analyzer-3.2.8.jar</Systempath> </Dependency>
For the war package system, sometimes you need to hit the jar package into the relevant war package, you can use plugin, by default, all the jar files under Lib are packaged under Web-inf/lib. Of course, you can also pack other documents, such as xml,properties and so on. The relevant plugin are as follows:
<plugin> <groupId>Org.apache.maven.plugins</groupId> <Artifactid>Maven-war-plugin</Artifactid> <version>2.3</version> <Configuration> <Warname>${project.artifactid}</Warname> <webresources> <Resource> <Directory>lib/</Directory> <TargetPath>Web-inf/lib</TargetPath> <includes> <include>**/*.jar</include> </includes> </Resource> </webresources> </Configuration> </plugin>
If it's lib or its own package,
<dependency>
<groupId>org.jvnet.hudson</groupId>
<artifactId>trilead-ssh2</artifactId>
<version>build212-hudson-6</version>
</dependency>
Add dependency packages and join local dependency packages when MAVEN is packaged