地址:https://github.com/roseboy/classfinal

下载和使用方式都有

java -jar classfinal-fatjar-1.2.1.jar -file server-cdzh-2.jar -packages com.ctsi -cfgfiles application-dev.yml,wechat.properties -pwd 123123 -Y

也可以用的maven插件模式

<plugin>
                <!-- https://gitee.com/roseboy/classfinal -->
                <groupId>net.roseboy</groupId>
                <artifactId>classfinal-maven-plugin</artifactId>
                <version>1.2.1</version>
                <configuration>
                    <!--                    无密码模式-->
                    <password>123123</password><!--加密打包之后pom.xml会被删除,不用担心在jar包里找到此密码-->
                    <packages>com.ctsi</packages>
                    <cfgfiles>application-dev.yml,wxpay.properties</cfgfiles>
                    <excludes>org.spring</excludes>
                    <libjars></libjars>
                </configuration>
                <executions>
                    <execution>
                        <phase>package</phase>
                        <goals>
                            <goal>classFinal</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>

注,我在加密配置文件的时候不成功,因为我的配置文件没有直接放在resources资源目录下,所以把配置文件拿出来才成功的

启动

java -javaagent:server-cdzh-3-encrypted.jar='-pwd' -jar server-cdzh-3-encrypted.jar -spring.profiles.active=dev

 启动的时候要输入密码

Logo

技术共进,成长同行——讯飞AI开发者社区

更多推荐