今天虚拟机安装了es6.8.10版本,想要springboot操作es测试一下,结果遇到了无法启动项目的情况
Caused by: java.lang.reflect.InaccessibleObjectException: Unable to make field private final java.math.BigInteger java.math.BigDecimal.intVal accessible: module java.base does not "opens java.math" to unnamed module @38d8f54a
at java.base/java.lang.reflect.AccessibleObject.checkCanSetAccessible(AccessibleObject.java:354) ~[na:na]
at java.base/java.lang.reflect.AccessibleObject.checkCanSetAccessible(AccessibleObject.java:297) ~[na:na]
at java.base/java.lang.reflect.Field.checkCanSetAccessible(Field.java:178) ~[na:na]
at java.base/java.lang.reflect.Field.setAccessible(Field.java:172) ~[na:na]
at org.springframework.util.ReflectionUtils.makeAccessible(ReflectionUtils.java:782) ~[spring-core-5.2.8.RELEASE.jar:5.2.8.RELEASE]
at org.springframework.data.mapping.context.AbstractMappingContext$PersistentPropertyCreator.doWith(AbstractMappingContext.java:500) ~[spring-data-commons-2.2.9.RELEASE.jar:2.2.9.RELEASE]
at org.springframework.util.ReflectionUtils.doWithFields(ReflectionUtils.java:705) ~[spring-core-5.2.8.RELEASE.jar:5.2.8.RELEASE]
at org.springframework.data.mapping.context.AbstractMappingContext.addPersistentEntity(AbstractMappingContext.java:374) ~[spring-data-commons-2.2.9.RELEASE.jar:2.2.9.RELEASE]
at java.base/java.util.Collections$SingletonSet.forEach(Collections.java:4905) ~[na:na]
at org.springframework.data.mapping.context.AbstractMappingContext$PersistentPropertyCreator.createAndRegisterProperty(AbstractMappingContext.java:548) ~[spring-data-commons-2.2.9.RELEASE.jar:2.2.9.RELEASE]
at org.springframework.data.mapping.context.AbstractMappingContext$PersistentPropertyCreator.doWith(AbstractMappingContext.java:506) ~[spring-data-commons-2.2.9.RELEASE.jar:2.2.9.RELEASE]
at org.springframework.util.ReflectionUtils.doWithFields(ReflectionUtils.java:705) ~[spring-core-5.2.8.RELEASE.jar:5.2.8.RELEASE]
at org.springframework.data.mapping.context.AbstractMappingContext.addPersistentEntity(AbstractMappingContext.java:374) ~[spring-data-commons-2.2.9.RELEASE.jar:2.2.9.RELEASE]
at org.springframework.data.mapping.context.AbstractMappingContext.getPersistentEntity(AbstractMappingContext.java:248) ~[spring-data-commons-2.2.9.RELEASE.jar:2.2.9.RELEASE]
at org.springframework.data.mapping.context.AbstractMappingContext.getPersistentEntity(AbstractMappingContext.java:191) ~[spring-data-commons-2.2.9.RELEASE.jar:2.2.9.RELEASE]
at org.springframework.data.mapping.context.AbstractMappingContext.getPersistentEntity(AbstractMappingContext.java:85) ~[spring-data-commons-2.2.9.RELEASE.jar:2.2.9.RELEASE]
at org.springframework.data.repository.core.support.RepositoryFactoryBeanSupport.lambda$afterPropertiesSet$4(RepositoryFactoryBeanSupport.java:295) ~[spring-data-commons-2.2.9.RELEASE.jar:2.2.9.RELEASE]
at java.base/java.util.Optional.ifPresent(Optional.java:178) ~[na:na]
at org.springframework.data.repository.core.support.RepositoryFactoryBeanSupport.afterPropertiesSet(RepositoryFactoryBeanSupport.java:295) ~[spring-data-commons-2.2.9.RELEASE.jar:2.2.9.RELEASE]
at org.springframework.data.elasticsearch.repository.support.ElasticsearchRepositoryFactoryBean.afterPropertiesSet(ElasticsearchRepositoryFactoryBean.java:67) ~[spring-data-elasticsearch-3.2.9.RELEASE.jar:3.2.9.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1853) ~[spring-beans-5.2.8.RELEASE.jar:5.2.8.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1790) ~[spring-beans-5.2.8.RELEASE.jar:5.2.8.RELEASE]
... 43 common frames omitted
大致看了一下,我认为是自定义类当中bigdecmal类型的问题,说是不能编译私有最终类Bigdecmal什么的
java.lang.reflect.InaccessibleObjectException: Unable to make field private final java.math.BigInteger java.math.BigDecimal.intVal accessible: module java.base does not "opens java.math" to unnamed module @38d8f54a
自定义类:
public class ESGoods{
private static final long serialVersionUID = 8509683142547327975L;
/**
* 商品id列
*/
@Id
private Long id;
/**
* 商品名称
*/
@Field(type = FieldType.Text, analyzer = "ik_smart", searchAnalyzer = "ik_smart")
private String goodsName;
/**
* 分类名称
*/
@Field(type = FieldType.Keyword)
private String spuName;
/**
* 商品品牌名称
*/
@Field(type = FieldType.Keyword)
private String goodsBrandName;
/**
* 商品价格
*/
@Field(type = FieldType.Double)
private BigDecimal amount;
/**
* 商品描述
*/
@Field(type = FieldType.Text, analyzer = "ik_smart", searchAnalyzer = "ik_smart")
private String description;
}
( 因为我用的是jdk17,第一次使用,也不知道是不是跟jdk版本有关 )
######我尝试将字段类型改为Double再运行了一下
/**
* 商品价格
*/
@Field(type = FieldType.Double)
private Double amount;
启动成功
2022-01-11 20:03:52.129 INFO [shop-elasticsearch] [traceId:][spanId:][parentSpanId:] --- [main] - [org.springframework.boot.SpringApplication:logStartupProfileInfo: 655] - The following profiles are active: dev
2022-01-11 20:03:53.421 INFO [shop-elasticsearch] [traceId:][spanId:][parentSpanId:] --- [main] - [org.apache.juli.logging.DirectJDKLog:log: 173] - Starting service [Tomcat]
2022-01-11 20:03:53.421 INFO [shop-elasticsearch] [traceId:][spanId:][parentSpanId:] --- [main] - [org.apache.juli.logging.DirectJDKLog:log: 173] - Starting Servlet engine: [Apache Tomcat/9.0.37]
2022-01-11 20:03:53.528 INFO [shop-elasticsearch] [traceId:][spanId:][parentSpanId:] --- [main] - [org.apache.juli.logging.DirectJDKLog:log: 173] - Initializing Spring embedded WebApplicationContext
2022-01-11 20:03:54.444 WARN [shop-elasticsearch] [traceId:][spanId:][parentSpanId:] --- [I/O dispatcher 1] - [org.elasticsearch.client.RequestLogger:logResponse: 65] - request [PUT http://192.168.153.129:9200/es_goods/_mapping/esgoods?master_timeout=30s&include_type_name=true&timeout=30s] returned 1 warnings: [299 Elasticsearch-6.8.10-537cb22 "[types removal] Specifying types in put mapping requests is deprecated. To be compatible with 7.0, the mapping definition should not be nested under the type name, and the parameter include_type_name must be provided and set to false."]
2022-01-11 20:03:54.586 INFO [shop-elasticsearch] [traceId:][spanId:][parentSpanId:] --- [main] - [com.netflix.config.sources.URLConfigurationSource:<init>: 126] - URLs to be used as dynamic configuration source: [file:/E:/ideajavaproject/spring-cloud-shop/shop-elasticsearch/shop-elasticsearch-api/target/classes/config.properties]
2022-01-11 20:03:54.590 INFO [shop-elasticsearch] [traceId:][spanId:][parentSpanId:] --- [main] - [com.netflix.config.sources.URLConfigurationSource:<init>: 126] - URLs to be used as dynamic configuration source: [file:/E:/ideajavaproject/spring-cloud-shop/shop-elasticsearch/shop-elasticsearch-api/target/classes/config.properties]
2022-01-11 20:03:55.919 INFO [shop-elasticsearch] [traceId:][spanId:][parentSpanId:] --- [main] - [org.springframework.boot.StartupInfoLogger:logStarted: 61] - Started Elasticsearch in 4.99 seconds (JVM running for 6.032)
2022-01-11 20:03:56.026 INFO [shop-elasticsearch] [traceId:][spanId:][parentSpanId:] --- [RMI TCP Connection(2)-192.168.153.1] - [org.apache.juli.logging.DirectJDKLog:log: 173] - Initializing Spring DispatcherServlet 'dispatcherServlet'
想请教知道的大lao解析一下是为何,越详细越好,感激不尽!