小编Gra*_*mak的帖子

在库中使用Proguard有一个应该自动装配的@Service bean

我有一个库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)

obfuscation spring proguard autowired

8
推荐指数
1
解决办法
5763
查看次数

Hibernate抛出HibernateQueryException:无法解析属性

所以我有一个表,我在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)

java spring hibernate

8
推荐指数
2
解决办法
5万
查看次数

使用Proguard和一个名为Spring @Autowired的库

我正在使用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等) .

任何人都知道我一般如何做到这一点?

格兰特

obfuscation spring proguard autowired

7
推荐指数
1
解决办法
1859
查看次数

标签 统计

spring ×3

autowired ×2

obfuscation ×2

proguard ×2

hibernate ×1

java ×1