package-info.java + Hibernate annotation @TypeDefs + Maven



如何在单独的package-info.java类上声明@TypeDefs,并将其与@Type一起使用包级别。目前我已按以下方式宣布。但当我用Maven编译应用程序时,它会给出以下错误。谢谢

package-info.java类

@TypeDefs
        ({
                @TypeDef(
                        name="encryptedString",
                        typeClass=EncryptedStringType.class,
                        parameters={
                                @Parameter(name="encryptorRegisteredName",
                                        value="rcmHibernateStringEncryptor")
                        }
                )
        })
package com.core.model;
import org.hibernate.annotations.TypeDef;
import org.hibernate.annotations.TypeDefs;
import org.hibernate.annotations.Parameter;
import org.jasypt.hibernate4.type.EncryptedStringType;

Maven错误

[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:2.3.2:compile (default-compile) on project MyApp: Compilation failure
[ERROR] comcoremodelpackage-infor.java:[2,0] error: package annotations should be in file package-info.java

您需要将package-infor.java重命名为package-info.java

其中应包含以下内容:

@TypeDefs({
    @TypeDef(
        name="encryptedString",
        typeClass=EncryptedStringType.class,
        parameters={
            @Parameter(name="encryptorRegisteredName",
                value="rcmHibernateStringEncryptor")
        }
    )
})    
package com.core.model;
import org.hibernate.annotations.TypeDef;
import org.hibernate.annotations.TypeDefs;
import org.hibernate.annotations.Parameter;
import org.jasypt.hibernate4.type.EncryptedStringType;

相关内容

  • 没有找到相关文章

最新更新