我有一个库Common.License,我与Proguard混淆:
<plugin>
<groupId>com.pyx4me</groupId>
<artifactId>proguard-maven-plugin</artifactId>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>proguard</goal>
</goals>
</execution>
</executions>
<configuration>
<obfuscate>true</obfuscate>
<options>
<option>-dontoptimize</option>
<option>-renamesourcefileattribute SourceFile</option>
<option>-keepattributes Exceptions,InnerClasses,Signature,Deprecated,SourceFile,LineNumberTable,*Annotation*,EnclosingMethod</option>
<option>-keep public class * { public protected *;}</option>
<option>-keepclassmembernames class * {java.lang.Class class$(java.lang.String); java.lang.Class class$(java.lang.String, boolean);}</option>
<option>-keepclassmembernames class * {com.common.license.LicenseSessionStore licenseSessionStore; com.common.license.LicenseStore licenseStore;}</option>
<option>-keepclassmembers enum * {public static **[] values(); public static ** valueOf(java.lang.String);}</option>
<option>-keepclassmembers class * implements java.io.Serializable { static final long serialVersionUID; private static final java.io.ObjectStreamField[] serialPersistentFields; private void writeObject(java.io.ObjectOutputStream); private void readObject(java.io.ObjectInputStream); java.lang.Object writeReplace(); java.lang.Object readResolve();}</option>
</options> …Run Code Online (Sandbox Code Playgroud) 所以我有一个表,我在hibernate中定义为这样的实体:
@Entity
@Table(name = "sec_Preference")
public class Preference {
private long id;
@Column(name = "PreferenceId", nullable = false, insertable = true, updatable = true, length = 19, precision = 0)
@GeneratedValue(strategy = GenerationType.AUTO)
@Id
public long getId() {
return id;
}
public void setId(long id) {
this.id = id;
}
private long systemuserid;
@Column(name = "SystemUserId", nullable = true, insertable = true, updatable = true, length = 19, precision = 0)
@Basic
public long getSystemUserId() {
return systemuserid;
}
public …Run Code Online (Sandbox Code Playgroud) 我正在使用Proguard来混淆具有多个@Autowired字段的库.混淆器正在重命名那些类字段(因为它们是类的私有/内部),因此我的bean无法实例化.
预混淆:
@Service
public class LicenseServiceImpl implements LicenseService {
@Autowired(required = false)
LicenseSessionStore licenseSessionStore;
@Autowired(required = false)
LicenseStore licenseStore;
...
}
Run Code Online (Sandbox Code Playgroud)
后期模糊处理:
@Service
public class LicenseServiceImpl implements LicenseService {
@Autowired(required=false)
LicenseSessionStore a;
@Autowired(required=false)
LicenseStore b;
...
}
Run Code Online (Sandbox Code Playgroud)
现在可能有很多方法可以使这些特定字段无法自动连接,但我希望找到的方法是告诉Proguard不要混淆任何带有重要Spring-isms注释的内部字段(@Autowired等) .
任何人都知道我一般如何做到这一点?
格兰特