详细解释 集成Maven Spring Mybatis项目包生成Bat文件
有时在项目必须Maven项目包生成bat文件,长官一人。本文将解释的具体使用方法maven-assembly-plugin插件实现bat文件包。
1.首先看一下项目结构
2.配置pom.xml文件,在节点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文件内容
<span style="font-family:KaiTi_GB2312;font-size:18px;"><assembly
xmlns="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>
<!-- 相应src/java/resources/相关文件 -->
<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.编写bat批处理文件
<span style="font-family:KaiTi_GB2312;font-size:18px;">@title Lachesis Synchronous_DrugBagRec_Datas %1 @echo %~dp0
echo off
rem Guess MNIS_HOME if not defined
set "CURRENT_DIR=%cd%"
if not "%MNIS_HOME%" == "" goto gotHome
set "MNIS_HOME=%CURRENT_DIR%"
if exist "%MNIS_HOME%\bin\run_midware.bat" goto okHome
set "MNIS_HOME=%~dp0.."
cd "%CURRENT_DIR%" :gotHome
if exist "%MNIS_HOME%\bin\run_midware.bat" goto okHome
echo The MNIS_HOME environment variable is not defined correctly
echo This environment variable is needed to run this program
goto end :okHome
if "%1" == "" goto startup :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
:end
pause</span>
4.选择项目,运行Maven Install
在target下会生成zip包。解压后,执行bin下的bat文件,就能够执行了。
版权声明:本文博客原创文章,博客,未经同意,不得转载。
详细解释 集成Maven Spring Mybatis项目包生成Bat文件的更多相关文章
- 用 Eclipse 搭建一个简单的 Maven spring mybatis 项目(包含测试用例)
1: 先搭建一个Maven项目: 创建好后的目录: 2: 配置pom.xml文件: <project xmlns="http://maven.apache.org/POM/4.0.0& ...
- idea 创建的maven+spring+mybatis项目整合 报错无法创建bean
报错如下: Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with n ...
- mybatis学习笔记(五) -- maven+spring+mybatis从零开始搭建整合详细过程(附demo和搭建过程遇到的问题解决方法)
文章介绍结构一览 一.使用maven创建web项目 1.新建maven项目 2.修改jre版本 3.修改Project Facts,生成WebContent文件夾 4.将WebContent下的两个文 ...
- mybatis学习笔记(六) -- maven+spring+mybatis从零开始搭建整合详细过程(下)
继续 mybatis学习笔记(五) -- maven+spring+mybatis从零开始搭建整合详细过程(上) 五.使用监听器启动Spring容器 1.修改pom.xml文件,添加Spring-we ...
- maven,spring,mybatis集成错误
maven,spring,mybatis集成的时候单元测试junit测试没问题,但mvn jetty:run 就报错误 错误: org.apache.ibatis.binding.BindingExc ...
- maven spring mybatis配置注意点
以下对使用maven配置spring+mybatis项目时,完成基本的配置需要添加的一些信息进行说明.仅对mybatis部分进行列举. maven添加mybatis支持 <!-- mybatis ...
- 用Eclipse 搭建一个Maven Spring SpringMVC 项目
1: 先创建一个maven web 项目: 可以参照之前的文章: 用Maven 创建一个 简单的 JavaWeb 项目 创建好之后的目录是这样的; 2: 先配置maven 修改pom.xml & ...
- IntelliJ IDEA上创建maven Spring MVC项目
IntelliJ IDEA上创建Maven Spring MVC项目 各软件版本 利用maven骨架建立一个webapp 建立相应的目录 配置Maven和SpringMVC 配置Maven的pom.x ...
- maven Spring MVC项目
IntelliJ IDEA上创建maven Spring MVC项目 各软件版本 利用maven骨架建立一个webapp 建立相应的目录 配置Maven和SpringMVC 配置Maven的pom.x ...
随机推荐
- 关与 Visual.Assist.X.V10.7.1912的Crack破解补丁(vs 番茄插件的key破解方法)
在win7系统下, 我用的是vs2012版本号. Visual Assist沿用了快10年的界面,最终有了更新,变得更加适合Win8 以及 VS2012的主题风格了 ,这也是以后软件的发展趋势,仅仅是 ...
- 采用Eclipse中间Maven构建Web项目错误(一)
采用Eclipse中间Maven构建Web工程 1.在进行上述操作时.pom.xml一直报错 <project xmlns="http://maven.apache.org/POM/4 ...
- Web Reference for a WCF Service has Extra “IdSpecified” Parameter ?
Question: I created a WCF service that exposed a method that has one paramater: public class Service ...
- 如何区分MNO和MVNO
MVNO(Mobile Virtaul Network Operator)虚拟网络运营商,没有自己的物理网络,租用MNO(Mobile Network Operator)网络提供的网络服务. 我们知道 ...
- 【SEO 决胜网络索引】 课程大纲及第一部分第一课:网络营销战略中的索引
内容简介 1.课程大纲 2.第一部分第一课: 网络营销战略中的索引 3.第一部分第二课预告: 索引是什么 课程大纲 现在是网络为王的时代,人们越来越离不开互联网: SEO(Search Engine ...
- groovy : poi 导出 Excel
參考 poi-3.10-FINAL/docs/spreadsheet/quick-guide.html write_xls.groovy 代码例如以下 package xls; import java ...
- Java一流的施工顺序
1.没有对象的构造 public class Test { public static int k = 0; public static int n = 99; public static int i ...
- poj 4088:Set操作
poj 4088:集合运算 题目:(至于4089.那个问题做过.使用归并思想,所以没有写) 描写叙述 小张须要从一批数量庞大的正整数中挑选出第k小的数.由于数据量太庞大,挑选起来非常费劲,希望你能编程 ...
- HDU 1085-Holding Bin-Laden Captive!(生成功能)
Holding Bin-Laden Captive! Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Ja ...
- ProducerConsumerDemo
package algorithm; public class ProducerConsumer { public static void main(String[] args) { SyncStac ...