首先再Maven中配置打包相关:
<profiles>
<profile>
<id>portable</id>
<activation>
<property>
<name>portable</name>
<value>true</value>
</property>
</activation>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>1.4</version>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
</execution>
</executions>
<configuration>
<shadedArtifactAttached>true</shadedArtifactAttached> <!-- Make the shaded artifact not the main one -->
<shadedClassifierName>shaded</shadedClassifierName> <!-- set the suffix to the shaded jar -->
</configuration>
</plugin>
<plugin>
<groupId>com.akathist.maven.plugins.launch4j</groupId>
<artifactId>launch4j-maven-plugin</artifactId>
<executions>
<execution>
<id>l4j-cli</id>
<phase>package</phase>
<goals>
<goal>launch4j</goal>
</goals>
<configuration>
<headerType>gui</headerType>
<outfile>target/Application.exe</outfile>
<jar>target/${artifactId}-${version}-shaded.jar</jar>
<errTitle>System Error</errTitle>
<icon>app/logo.ico</icon>
<classPath>
<mainClass>net.lainiao.dicom.MaskerApplication</mainClass>
</classPath>
<jre>
<minVersion>1.8.0</minVersion>
<initialHeapSize>128</initialHeapSize>
<maxHeapSize>1024</maxHeapSize>
<path>./jre</path>
</jre>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
</profiles>
激活该配置:
执行 maven install:
效果图:
在打包好的Application.exe就是可以运行的Exe程序,要是想要直接运行的话,还需要配置拷入Jre文件才能运行:
程序源代码 :
GitHub - lainiao/dicommasker: Java implementation of the Dicom file desensitization tool
打包好程序下载: