H2 - 发生了非法的反射访问操作
H2 - An illegal reflective access operation has occurred
启动我的 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
结果我的 table 有一个 Coder 列,而不是像我的实体那样的实际名称 -
@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 ...
};
感谢您的帮助,如果需要更多代码,请在下方评论。
将 EmbeddedId
替换为 Id
,如下所示:
import javax.persistence.Id;
@Entity
public class TaxValuesEntity {
@Id
public String countryCodePK;
EmbeddedId
用于复合主键。
我对 JDK11 和 Mockito 也有类似的问题。解决方法是使用最新版本的 Mockito。也许检查 Hibernate 的版本和 JDK 11 的当前支持状态。在快速搜索中,找到了这个 using hibernate with jdk11 and hibernate release 5.4
启动我的 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
结果我的 table 有一个 Coder 列,而不是像我的实体那样的实际名称 -
@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 ...
};
感谢您的帮助,如果需要更多代码,请在下方评论。
将 EmbeddedId
替换为 Id
,如下所示:
import javax.persistence.Id;
@Entity
public class TaxValuesEntity {
@Id
public String countryCodePK;
EmbeddedId
用于复合主键。
我对 JDK11 和 Mockito 也有类似的问题。解决方法是使用最新版本的 Mockito。也许检查 Hibernate 的版本和 JDK 11 的当前支持状态。在快速搜索中,找到了这个 using hibernate with jdk11 and hibernate release 5.4