版权声明:署名,允许他人基于本文进行创作,且必须基于与原先许可协议相同的许可协议分发本文 (Creative Commons)
背景:
最近的几个项目交给我负责了,但是源码丢了,只有编译后的war包和jar包。WTF!不过class文件还是可以反编译为java文件的,使用jd-gui反编译工具。然后再新建project就可以。
jd-gui下载地址:https://www.softpedia.com/get/Programming/Debuggers-Decompilers-Dissasemblers/JD-GUI.shtml
idea使用maven引入外部依赖目录并打包为可执行的jar包
1、为了图省事不想一个一个去找war包中依赖的jar包,直接将lib依赖引入
pom.xml:
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.xxx</groupId>
<artifactId>api-invoke-fix</artifactId>
<version>0.0.1-SNAPSHOT</version>
<!-- <packaging>war</packaging>-->
<packaging>jar</packaging>
<name>api-invoke-fix</name>
<description>Demo project for Spring Boot</description>
<properties>
<java.version>1.8</java.version>
</properties>
<dependencies>
</dependencies>
<build>
<resources>
<resource>
<directory>${project.basedir}/src/main/resources</directory>
</resource>
<resource>
<directory>lib/</directory>
<targetPath>${project.build.outputDirectory}/BOOT-INF/lib</targetPath>
<includes>
<include>*.jar</include>
</includes>
</resource>
</resources>
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>1.8</source>
<target>1.8</target>
<encoding>UTF-8</encoding>
<compilerArguments>
<extdirs>lib</extdirs>
</compilerArguments>
</configuration>
</plugin>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<version>1.5.10.RELEASE</version>
<executions>
<execution>
<goals>
<goal>repackage</goal>
</goals>
</execution>
</executions>
<configuration>
<!--<includeSystemScope>true</includeSystemScope>-->
</configuration>
</plugin>
</plugins>
</build>
</project>
也可以使用:
<dependency>
<groupId>xxx.xxxx</groupId>
<artifactId>xxx</artifactId>
<version>1.5</version>
<scope>system</scope>
<systemPath>${project.basedir}/lib/xxx.jar</systemPath>
</dependency>
includeSystemScope配置要为true