有时在项目必须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文件的更多相关文章

  1. 用 Eclipse 搭建一个简单的 Maven spring mybatis 项目(包含测试用例)

    1: 先搭建一个Maven项目: 创建好后的目录: 2: 配置pom.xml文件: <project xmlns="http://maven.apache.org/POM/4.0.0& ...

  2. idea 创建的maven+spring+mybatis项目整合 报错无法创建bean

    报错如下: Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with n ...

  3. mybatis学习笔记(五) -- maven+spring+mybatis从零开始搭建整合详细过程(附demo和搭建过程遇到的问题解决方法)

    文章介绍结构一览 一.使用maven创建web项目 1.新建maven项目 2.修改jre版本 3.修改Project Facts,生成WebContent文件夾 4.将WebContent下的两个文 ...

  4. mybatis学习笔记(六) -- maven+spring+mybatis从零开始搭建整合详细过程(下)

    继续 mybatis学习笔记(五) -- maven+spring+mybatis从零开始搭建整合详细过程(上) 五.使用监听器启动Spring容器 1.修改pom.xml文件,添加Spring-we ...

  5. maven,spring,mybatis集成错误

    maven,spring,mybatis集成的时候单元测试junit测试没问题,但mvn jetty:run 就报错误 错误: org.apache.ibatis.binding.BindingExc ...

  6. maven spring mybatis配置注意点

    以下对使用maven配置spring+mybatis项目时,完成基本的配置需要添加的一些信息进行说明.仅对mybatis部分进行列举. maven添加mybatis支持 <!-- mybatis ...

  7. 用Eclipse 搭建一个Maven Spring SpringMVC 项目

    1: 先创建一个maven web  项目: 可以参照之前的文章:  用Maven 创建一个 简单的 JavaWeb 项目 创建好之后的目录是这样的; 2: 先配置maven  修改pom.xml & ...

  8. IntelliJ IDEA上创建maven Spring MVC项目

    IntelliJ IDEA上创建Maven Spring MVC项目 各软件版本 利用maven骨架建立一个webapp 建立相应的目录 配置Maven和SpringMVC 配置Maven的pom.x ...

  9. maven Spring MVC项目

    IntelliJ IDEA上创建maven Spring MVC项目 各软件版本 利用maven骨架建立一个webapp 建立相应的目录 配置Maven和SpringMVC 配置Maven的pom.x ...

随机推荐

  1. 说说nio2

    利不百不变法,功不十不易器 为什么会出现nio,之前的io有什么问题? 请先看 说说nio1 nio类图例如以下 watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZX ...

  2. APK 代码混淆

    # To enable ProGuard in your project, edit project.properties # to define the proguard.config proper ...

  3. Android - match_parent 和 fill_parent差异

    Android - match_parent 和 fill_parent差异 本文地址: http://blog.csdn.net/caroline_wendy match_parent 和 fill ...

  4. 【新秀疯狂UML系列】——面向对象的技术

    从软质工作开始,我们来到与面向对象的接触,接下来的学习材料似乎已经提到了面向对象,在与她的朋友去一个.所以,我们必须知道她多一点点. 一.何为面向对象? 面向对象(Object Oriented).是 ...

  5. Effective C++笔记05:实现

    条款26:尽可能延后变量定义式的出现时间 博客地址:http://blog.csdn.net/cv_ronny 转载请注明出处! 有些对象,你可能过早的定义它,而在代码运行的过程中发生了导常,造成了開 ...

  6. 什么时候PHP经验MySQL存储过程

    1.MySQL存储过程 数据库语言,我们经常使用的操作SQL语句必须首先编译在运行时.然后运行,存储过程(Stored Procedure)它被设置为完成一个特定的功能SQL报表设置.编译存储在数据库 ...

  7. PHP获取表单方法

    php接收HTML当表单提交的信息,数据将存储提交在全局阵列中,我们能够调用系统特定的自己主动全局变量数组来获取这些值.经常使用的自己主动全局变量例如以下所看到的: $_GET $_POST $_RE ...

  8. RH133读书笔记(7)-Lab 7 Advanced Filesystem Mangement

    Lab 7 Advanced Filesystem Mangement Goal: Develop skills and knowlege related to Software RAID, LVM, ...

  9. Binary Tree Inorder Traversal(转)

    Given a binary tree, return the inorder traversal of its nodes' values. For example: Given binary tr ...

  10. quick-cocos2d-x游戏开发【3】——display.newSprite创建向导

    游戏嘛.没有图片没有图片可以称为你的游戏,所以,我们看一下使用quick如何创建精灵的方式. quick的api精灵族的创造仍然是非常具体的解释.因此,建立非常easy. display.newSpr ...