intellij-idea - 使用IDEA 打包 java程序,包括图片、配置文件等
伊谢尔伦
伊谢尔伦 2017-04-17 17:18:07
0
2
990

我用IDEA写了个java小程序,想打包成可执行的jar文件,发到别的电脑使用。
但是打包老是出问题,不是运行不了就是运行了之后,没有图标和我另外加入的图片。
还有个问题就是我给程序增加了配置文件,但是打包的时候被打包到jar里面去了,导致我无法修改配置文件。
麻烦大家有遇到这方面问题或者有经验的帮忙解答一下。

伊谢尔伦
伊谢尔伦

小伙看你根骨奇佳,潜力无限,来学PHP伐。

reply all(2)
Peter_Zhu

maven project:
Use the maven-assembly-plugin plug-in
For usage, please refer to http://www.infoq.com/cn/news/2011/06/xxb-maven-9-package
For example,
assembly.xml needs to be The configuration file is packaged in a separate folder and can be configured as follows
<assembly>

<id>assembly</id>
<formats>
    <format>tar.gz</format>
</formats>
<includeBaseDirectory>true</includeBaseDirectory>
<fileSets>
    <fileSet>
        <directory>src/main/assembly/bin</directory>
        <outputDirectory>bin</outputDirectory>
        <fileMode>0755</fileMode>
    </fileSet>
    <fileSet>
        <directory>src/main/resources/${package.environment}</directory>
        <outputDirectory>conf</outputDirectory>
        <fileMode>0644</fileMode>
    </fileSet>
    <fileSet>
        <directory>lib/</directory>
        <outputDirectory>lib</outputDirectory>
    </fileSet>
</fileSets>
<dependencySets>
    <dependencySet>
        <outputDirectory>lib</outputDirectory>
    </dependencySet>
</dependencySets>

</assembly>
When writing the bin startup script, you need to include the conf directory in the classpath

阿神

It would be more troublesome to package the resources yourself. For various configurations, you can try spring-boot

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!