Detailed integrated MAVEN Spring MyBatis Project Package build BAT file

Source: Internet
Author: User

In a project, you sometimes need to package a MAVEN project to generate a bat file and run it separately. This article will explain the use of Maven-assembly-plugin plug-in implementation of BAT file packaging.

1. First look at the project structure


2. Configure the Pom.xml file to include the following configuration in the node build

<span style= "FONT-FAMILY:KAITI_GB2312;FONT-SIZE:18PX;" ><resources><resource><directory>src/main/java</directory><includes>< Include>**/*.xml</include></includes></resource><resource><directory>src/main /resources</directory><excludes><exclude>src/main/resources/bin</exclude></excludes ></resource><resource><directory>src/main/resources/bin</directory><filtering >true</filtering><targetPath>bin</targetPath></resource></resources>< Plugins><plugin><artifactid>maven-jar-plugin</artifactid><configuration><archive ><manifest><mainClass>com.uih.anyi.mnis.drugbag.service.main.TestMain</mainClass>< addclasspath>true</addclasspath><classpathprefix>${lib.output.dir}</classpathprefix>< Useuniqueversions>false</useuniqueversions></manifest><manifestentries><class-path>.</class-path></manifestentries></archive><excludes>< exclude>properties/</exclude></excludes></configuration></plugin><plugin>< Artifactid>maven-assembly-plugin</artifactid><executions><execution><phase>package </phase><goals><goal>single</goal></goals></execution></executions> <configuration><descriptors><descriptor>assembly.xml</descriptor></descriptors> </configuration></plugin></plugins></build></span>
2.assembly.xml File Contents

<span style= "FONT-FAMILY:KAITI_GB2312;FONT-SIZE:18PX;" ><assemblyxmlns= "http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.2" xmlns:xsi= "http// Www.w3.org/2001/XMLSchema-instance "xsi:schemalocation=" http://maven.apache.org/plugins/maven-assembly-plugin/ assembly/1.1.2 http://maven.apache.org/xsd/assembly-1.1.2.xsd "><id>distribution</id><formats ><format>zip</format></formats><files><file><source>${ project.build.directory}/${project.build.finalname}.jar</source><outputdirectory>/</ outputdirectory></file></files><filesets><fileset><directory>${ Project.basedir}</directory><outputdirectory>/</outputdirectory><includes><include >readme*</include><include>license*</include><include>notice*</include></ includes></fileset><!--corresponding src/java/resources/related files--><fileset><directory>${project.build.outputdirectory}/bin/</directory><outputdirectory>/bin/</outputdirectory></ fileset><fileset><directory>${project.build.outputdirectory}/properties/</directory>< outputdirectory>/properties/</outputdirectory></fileset><fileset><directory>${ project.build.outputdirectory}/db/</directory><outputdirectory>/db/</outputdirectory></ fileset></filesets><dependencysets><dependencyset><outputdirectory>/${ lib.output.dir}</outputdirectory><scope>runtime</scope></dependencyset></ Dependencysets></assembly></span>

3. Writing a bat batch file

<span Style= "FONT-FAMILY:KAITI_GB2312;FONT-SIZE:18PX;" > @title lachesis synchronous_drugbagrec_datas%1@echo%~dp0echo offrem Guess mnis_home if not Definedset "CURRENT_DIR= %cd% "If not"%mnis_home% "= =" "Goto gothomeset" mnis_home=%current_dir% "if Exist"%mnis_home%\bin\run_midware.bat "goto Okhomeset "Mnis_home=%~dp0 ..." CD "%current_dir%": Gothomeif exist "%mnis_home%\bin\run_midware.bat" goto Okhomeecho the MNIS_HOME environment variable Is isn't defined Correctlyecho This environment variable was needed to run this Programgoto end:okhomeif "%1" = = "" Goto Star Tup:startup@set Classpath=%java_home%\lib;%java_home%\lib\dt.jar;%java_home%\lib\tools.jar;%mnis_home%\lib;java -xms32m-xmx128m-xx:maxnewsize=32m-xx:maxpermsize=128m-jar%mnis_home%\${project.build.finalname}.${ project.packaging}%1 &echo on:endpause</span> 

4. Select the project to perform MAVEN Install

A ZIP package is generated under target, and after extracting it, the bat file under the bin is executed and can be run.



Detailed integrated MAVEN Spring MyBatis Project Package build BAT file

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.