打包之后注入提示
required a bean of type ‘com.xxx.xxx‘ that could not be found
查询各种资料,研究了半天,一个配置就搞定
添加
<!-- 保持目录结构-->
<option>-keepdirectories</option>
pom.xml文件中添加入下配置
<build>
<finalName>${project.artifactId}-${project.version}</finalName>
<plugins>
<!--代码混淆插件-->
<plugin>
<groupId>com.github.wvengen</groupId>
<artifactId>proguard-maven-plugin</artifactId>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>proguard</goal>
</goals>
</execution>
</executions>
<configuration>
<proguardVersion>6.2.2</proguardVersion>
<injar>${project.build.finalName}.jar</injar>
<outjar>${project.build.finalName}.jar</outjar>
<obfuscate>true</obfuscate>
<options>
<option>-target 1.8</option>
<!-- ##默认是开启的,这里关闭shrink,即不删除没有使用的类/成员-->
<option>-dontshrink</option>
<!-- ##默认是开启的,这里关闭字节码级别的优化-->
<option>-dontoptimize</option>
<!--##对于类成员的命名的混淆采取唯一策略-->
<option>-useuniqueclassmembernames</option>
<!--- 混淆类名之后,对使用Class.forName(‘className‘)之类的地方进行相应替代-->
<option>-adaptclassstrings</option>
<option>-ignorewarnings</option>
<!-- 混淆时不生成大小写混合的类名,默认是可以大小写混合-->
<option>-dontusemixedcaseclassnames</option>
<!-- This option will replace all strings in reflections method invocations with new class names.
For example, invokes Class.forName(‘className‘)-->
<!-- <option>-adaptclassstrings</option> -->
<!-- This option will save all original annotations and etc. Otherwise all we be removed from files.-->
<!-- 不混淆所有特殊的类-->
<option>-keepattributes Exceptions,InnerClasses,Signature,Deprecated,
SourceFile,LineNumberTable,*Annotation*,EnclosingMethod
</option>
<!-- This option will save all original names in interfaces (without obfuscate).-->
<option>-keepnames interface **</option>
<!-- This option will save all original methods parameters in files defined in -keep sections,
otherwise all parameter names will be obfuscate.-->
<option>-keepparameternames</option>
<!-- 保持目录结构-->
<option>-keepdirectories</option>
<!-- 排除config文件夹-->
<option>-keep class com.hrms.framework.config.* { *; }</option>
<option>-keep class * implements java.io.Serializable</option>
<option>-keep interface * extends * { *; }</option>
<!-- 排除所有public class 和 method-->
<option>-keep public class * { public protected *; }
</option>
<!-- <option>-keep @org.springframework.stereotype.Service class *</option> -->
<!-- This option will save all original defined annotations in all class in all packages.-->
<option>-keepclassmembers class * {
<!-- @org.springframework.beans.factory.annotation.Autowired *; -->
@org.springframework.beans.factory.annotation.Value *;
}
</option>
</options>
<libs>
<!-- Include main JAVA library required.-->
<lib>${java.home}/lib/rt.jar</lib>
<!-- Include crypto JAVA library if necessary.-->
<lib>${java.home}/lib/jce.jar</lib>
</libs>
</configuration>
<dependencies>
<dependency>
<groupId>net.sf.proguard</groupId>
<artifactId>proguard-base</artifactId>
<version>6.2.2</version>
</dependency>
</dependencies>
</plugin>
</plugins>
</build>
springboot使用proguard代码混淆配置,解决混淆后扫描不到无法注入的问题
原文:https://www.cnblogs.com/zz4926/p/14808578.html