我们正在对Spring Boot应用程序进行混淆: 该应用程序中有很多组件,并且为组件提供了任何特定的名称,因为它们默认情况下采用类名,但是如果混淆,我们将在异常之下
@Component
public class Configuration
我们的项目中有很多组件。
例外:
ERROR - Application startup failed
org.springframework.beans.factory.BeanDefinitionStoreException: Failed to process import candidates for configuration class [com.Application]; nested exception is java.lang.IllegalArgumentException: No auto-configuration attributes found. Is com.Application annotated with EnableAutoConfiguration?
at org.springframework.context.annotation.ConfigurationClassParser.processDeferredImportSelectors(ConfigurationClassParser.java:556)
at org.springframework.context.annotation.ConfigurationClassParser.parse(ConfigurationClassParser.java:185)
at org.springframework.context.annotation.ConfigurationClassPostProcessor.processConfigBeanDefinitions(ConfigurationClassPostProcessor.java:308)
at org.springframework.context.annotation.ConfigurationClassPostProcessor.postProcessBeanDefinitionRegistry(ConfigurationClassPostProcessor.java:228)
at org.springframework.context.support.PostProcessorRegistrationDelegate.invokeBeanDefinitionRegistryPostProcessors(PostProcessorRegistrationDelegate.java:272)
at org.springframework.context.support.PostProcessorRegistrationDelegate.invokeBeanFactoryPostProcessors(PostProcessorRegistrationDelegate.java:92)
at org.springframework.context.support.AbstractApplicationContext.invokeBeanFactoryPostProcessors(AbstractApplicationContext.java:687)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:525)
at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:693)
at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:360)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:303)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1118)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1107)
at com.Application.main(Application.java:18)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.springframework.boot.loader.MainMethodRunner.run(MainMethodRunner.java:48)
at org.springframework.boot.loader.Launcher.launch(Launcher.java:87)
at org.springframework.boot.loader.Launcher.launch(Launcher.java:50)
at org.springframework.boot.loader.JarLauncher.main(JarLauncher.java:51)
Caused by: java.lang.IllegalArgumentException: No auto-configuration attributes found. Is com.Application annotated with EnableAutoConfiguration?
at org.springframework.util.Assert.notNull(Assert.java:193)
at org.springframework.boot.autoconfigure.AutoConfigurationImportSelector.getAttributes(AutoConfigurationImportSelector.java:126)
at org.springframework.boot.autoconfigure.AutoConfigurationImportSelector.selectImports(AutoConfigurationImportSelector.java:94)
at org.springframework.context.annotation.ConfigurationClassParser.processDeferredImportSelectors(ConfigurationClassParser.java:547)
... 21 common frames omitted
有人能提出比将名称显式添加到每个组件更好的方法吗?
**
更新
**
主类文件也具有以下注释
@SpringBootApplication(scanBasePackages = {
即使我们正在使用简单的演示项目并尝试对其进行模糊处理
@SpringBootApplication
public class DemoApplication {
public static void main(String[] args) {
SpringApplication.run(DemoApplication.class, args);
}
}
Proguard如何混淆与Spring相关的文件。我明确地保持所有罐子不被混淆。
org.springframework.beans.factory.BeanDefinitionStoreException:失败 处理配置类的导入候选 [com.example.demo.DemoApplication];嵌套异常为 java.lang.IllegalArgumentException:没有自动配置属性 找到了。 com.example.demo.DemoApplication带有注释 EnableAutoConfiguration?
已更新。添加proguard.conf文件
-libraryjars <java.home>/lib/rt.jar
#-include ../build/annotations.pro
-keeppackagenames
-keepdirectories
-dontshrink
-dontoptimize
-dontwarn
#-applymapping input_mapping.dat
#-printmapping final_mapping.dat
#-dontusemixedcaseclassnames
#-forceprocessing
-keepattributes InnerClasses,EnclosingMethod,SourceFile,LineNumberTable,Deprecated,Signature,Exceptions,*Annotations*
#-ignorewarnings
# Keep - Applications. Keep all application classes that have a main method.
-keep class !com.companyname.** { *; }
-keepclassmembers class * {
@org.springframework.beans.factory.annotation.* *;
}
-keepclassmembers class * {
@org.simpleframework.xml.* *;
}