Java Spring属性与Proguard的绑定
我使用Proguard混淆了下面的Spring配置类。我在下面给出了我使用的Proguard选项。该类应绑定到属性文件中名为Java Spring属性与Proguard的绑定,java,spring,spring-boot,proguard,Java,Spring,Spring Boot,Proguard,我使用Proguard混淆了下面的Spring配置类。我在下面给出了我使用的Proguard选项。该类应绑定到属性文件中名为http.cache.timeToLiveInDays的属性 @ConfigurationProperties(prefix = "onboarding", ignoreUnknownFields = false) public class OnboardingProperties { private final Http http = new Http();
http.cache.timeToLiveInDays
的属性
@ConfigurationProperties(prefix = "onboarding", ignoreUnknownFields = false)
public class OnboardingProperties {
private final Http http = new Http();
public Http getHttp() {
return http;
}
public static class Http {
private final Cache cache = new Cache();
public Cache getCache() {
return cache;
}
public static class Cache {
private int timeToLiveInDays = 1461;
public int getTimeToLiveInDays() {
return timeToLiveInDays;
}
public void setTimeToLiveInDays(final int timeToLiveInDays) {
this.timeToLiveInDays = timeToLiveInDays;
}
}
}
}
属性文件application.yml
包含以下内容:
onboarding:
http:
cache:
timeToLiveInDays: 1234
Proguard配置
-injars ../$FINAL_NAME$/WEB-INF/lib/$FINAL_NAME$.jar
-outjars ./
-dontoptimize
# -dontshrink
# -dontusemixedcaseclassnames
# -dontpreverify
-verbose
-printseeds seeds.txt
-optimizations !class/marking/final
-adaptresourcefilenames **.properties
-adaptresourcefilecontents **.properties,META-INF/MANIFEST.MF
-keep public class com.test.blah.OnboardingApp {
public static void main(java.lang.String[]);
}
-keep public class * extends org.springframework.boot.web.support.SpringBootServletInitializer
-keep class com.test.blah**.dto.** {
void set*(***);
*** get*();
}
-keep public class com.test.blah.config.OnboardingProperties
-keep public class com.test.blah.config.OnboardingProperties$* {
*;
}
-keep class org.springframework.**
-keep class liquibase.**
-keep interface org.springframework.**
-keep interface liquibase.**
-keepclassmembers class * {
@org.springframework.beans.factory.annotation.Autowired *;
@org.springframework.beans.factory.annotation.Qualifier *;
@org.springframework.beans.factory.annotation.Value *;
@org.springframework.beans.factory.annotation.Required *;
@org.springframework.context.annotation.Bean *;
@org.springframework.context.annotation.Primary *;
@org.springframework.boot.context.properties.ConfigurationProperties *;
@javax.inject.Inject *;
@javax.annotation.PostConstruct *;
@javax.annotation.PreDestroy *;
}
-keep @org.springframework.stereotype.Service class *
-keep @org.springframework.stereotype.Controller class *
-keep @org.springframework.stereotype.Component class *
-keep @org.springframework.stereotype.Repository class *
-keep @org.springframework.context.annotation.Configuration class *
-keep @org.springframework.web.bind.annotation.ControllerAdvice class *
-keep @org.springframework.boot.context.properties.ConfigurationProperties class *
-keep @org.springframework.boot.autoconfigure.SpringBootApplication class *
-allowaccessmodification
-keepattributes Deprecated,SourceFile,LineNumberTable,LocalVariable*Table,Synthetic,EnclosingMethod
-keepattributes *Annotation*
-keepattributes Signature
-keepattributes Exceptions
-keepattributes InnerClasses
-keepparameternames
-keepdirectories
-keepclassmembernames class * {
java.lang.Class class$(java.lang.String);
java.lang.Class class$(java.lang.String, boolean);
}
-keepclassmembers enum * {
public static **[] values();
public static ** valueOf(java.lang.String);
public static ** fromValue(java.lang.String);
}
-keepnames class * implements java.io.Serializable
-keepclassmembers class * implements java.io.Serializable {
static final long serialVersionUID;
private static final java.io.ObjectStreamField[] serialPersistentFields;
!static !transient <fields>;
!private <fields>;
!private <methods>;
private void writeObject(java.io.ObjectOutputStream);
private void readObject(java.io.ObjectInputStream);
java.lang.Object writeReplace();
java.lang.Object readResolve();
}
有什么办法可以解决这个问题吗?我设法用
-keep public class com.test.blah.config.OnboardingProperties {
private <fields>;
*** get*();
}
-keep class com.test.blah.config.OnboardingProperties$* {
private <fields>;
void set*(***);
*** get*();
}
-keep public class com.test.blah.config.OnboardingProperties {
private <fields>;
*** get*();
}
-keep class com.test.blah.config.OnboardingProperties$* {
private <fields>;
void set*(***);
*** get*();
}
-keep public class com.test.blah.config.OnboardingProperties
-keep public class com.test.blah.config.OnboardingProperties$* {
*;
}