H2-发生了非法的反射访问操作

时间:2018-12-16 11:19:28

标签: java spring-boot entity h2

启动我的spring-boot应用程序后出现警告-

WARNING: An illegal reflective access operation has occurred
WARNING: Illegal reflective access by org.hibernate.internal.util.ReflectHelper (file:/C:/Users/xxxx/.m2/repository/org/hibernate/hibernate-core/5.3.7.Final/hibernate-core-5.3.7.Final.jar) to field java.lang.String.coder
WARNING: Please consider reporting this to the maintainers of org.hibernate.internal.util.ReflectHelper
WARNING: Use --illegal-access=warn to enable warnings of further illegal reflective access operations
WARNING: All illegal access operations will be denied in a future release

结果是我的表有一个Coder列,而不是像Entity这样的实际名称-

@Entity
public class TaxValuesEntity {

    @EmbeddedId
    public String countryCodePK;
    public double taxValue;
    public Timestamp creationAt;
    public Timestamp modifedAt;

    protected TaxValuesEntity() {
    };

    public TaxValuesEntity(String countryCode, double taxValue, Timestamp creation, Timestamp modifed) {
        this.countryCodePK = countryCode;
        this.taxValue = taxValue;
        this.creationAt = creation;
        this.modifedAt = modifed;
    }
    //getters & setters ...
};

感谢您的帮助,如果需要更多代码,请在下面评论。

2 个答案:

答案 0 :(得分:1)

EmbeddedId替换为Id,如下所示:

import javax.persistence.Id;

@Entity
public class TaxValuesEntity {

    @Id
    public String countryCodePK;

EmbeddedId用于复合主键。

答案 1 :(得分:1)

我在JDK11和Mockito中遇到了类似的问题。解决方法是使用最新版本的Mockito。也许检查Hibernate的版本以及JDK 11的当前支持状态。在快速搜索中,找到了using hibernate with jdk11hibernate release 5.4