我正在使用 Proguard 来混淆具有多个 @Autowired 字段的库。混淆器正在重命名这些类字段(因为它们是类的私有(private)/内部),因此我的 bean 无法实例化。
预混淆:
@Service
public class LicenseServiceImpl implements LicenseService {
@Autowired(required = false)
LicenseSessionStore licenseSessionStore;
@Autowired(required = false)
LicenseStore licenseStore;
...
}
后混淆:
@Service
public class LicenseServiceImpl implements LicenseService {
@Autowired(required=false)
LicenseSessionStore a;
@Autowired(required=false)
LicenseStore b;
...
}
现在可能有很多方法可以使这些特定字段不自动连接,但我希望找到一种方法来告诉 Proguard 不要混淆任何带有重要 Spring-isms 注释的内部字段(@Autowired 等) .
任何人都知道我通常如何做到这一点?
授予
最佳答案
我在为 simplexml 注释类保留类名时遇到了类似的问题。我的解决方法是添加以下内容:
-keepclassmembers class * {
@org.simpleframework.xml.* *;
}
我认为类似的东西对你有用:
-keepclassmembers class * {
@org.springframework.beans.factory.annotation.* *;
}
关于spring - 将 Proguard 与按名称使用 Spring @Autowired 的库一起使用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4400213/