在我的spring-boot maven项目中,其中一个依赖项是spring-data-commons
。它扫描我的项目中的类并抛出StackOverflow错误。它不喜欢的课程如下,
class TreeNode<T> {
private T someData = null;
private List<TreeNode<T>> children = new ArrayList<>();
}
我认为它正在对字段尝试一些反射机制,然后由于某些不确定的循环而失败。 在spring-boot应用程序启动期间记录日志。
Caused by: java.lang.StackOverflowError
at java.util.AbstractMap.hashCode(AbstractMap.java:528) ~[?:1.8.0_121]
at org.springframework.util.ObjectUtils.nullSafeHashCode(ObjectUtils.java:396) ~[spring-core-4.3.8.RELEASE.jar:4.3.8.RELEASE]
at org.springframework.core.ResolvableType.calculateHashCode(ResolvableType.java:865) ~[spring-core-4.3.8.RELEASE.jar:4.3.8.RELEASE]
at org.springframework.core.ResolvableType.<init>(ResolvableType.java:140) ~[spring-core-4.3.8.RELEASE.jar:4.3.8.RELEASE]
at org.springframework.core.ResolvableType.forType(ResolvableType.java:1349) ~[spring-core-4.3.8.RELEASE.jar:4.3.8.RELEASE]
at org.springframework.core.ResolvableType.forType(ResolvableType.java:1320) ~[spring-core-4.3.8.RELEASE.jar:4.3.8.RELEASE]
at org.springframework.core.GenericTypeResolver.resolveType(GenericTypeResolver.java:260) ~[spring-core-4.3.8.RELEASE.jar:4.3.8.RELEASE]
at org.springframework.data.util.TypeDiscoverer.resolveType(TypeDiscoverer.java:186) ~[spring-data-commons-1.13.3.RELEASE.jar:?]
at org.springframework.data.util.TypeDiscoverer.createInfo(TypeDiscoverer.java:128) ~[spring-data-commons-1.13.3.RELEASE.jar:?]
at org.springframework.data.util.ParentTypeAwareTypeInformation.createInfo(ParentTypeAwareTypeInformation.java:73) ~[spring-data-commons-1.13.3.RELEASE.jar:?]
at org.springframework.data.util.TypeDiscoverer.getPropertyInformation(TypeDiscoverer.java:246) ~[spring-data-commons-1.13.3.RELEASE.jar:?]
at org.springframework.data.util.TypeDiscoverer.getProperty(TypeDiscoverer.java:221) ~[spring-data-commons-1.13.3.RELEASE.jar:?]
at org.springframework.data.util.ParentTypeAwareTypeInformation.getProperty(ParentTypeAwareTypeInformation.java:28) ~[spring-data-commons-1.13.3.RELEASE.jar:?]
at org.springframework.data.mapping.model.AbstractPersistentProperty.<init>(AbstractPersistentProperty.java:66) ~[spring-data-commons-1.13.3.RELEASE.jar:?]
at org.springframework.data.mapping.model.AnnotationBasedPersistentProperty.<init>(AnnotationBasedPersistentProperty.java:68) ~[spring-data-commons-1.13.3.RELEASE.jar:?]
at org.springframework.data.neo4j.mapping.Neo4jPersistentProperty.<init>(Neo4jPersistentProperty.java:74) ~[spring-data-neo4j-4.2.3.RELEASE.jar:?]
at org.springframework.data.neo4j.mapping.Neo4jMappingContext.createPersistentProperty(Neo4jMappingContext.java:95) ~[spring-data-neo4j-4.2.3.RELEASE.jar:?]
at org.springframework.data.neo4j.mapping.Neo4jMappingContext.createPersistentProperty(Neo4jMappingContext.java:42) ~[spring-data-neo4j-4.2.3.RELEASE.jar:?]
at org.springframework.data.mapping.context.AbstractMappingContext$PersistentPropertyCreator.createAndRegisterProperty(AbstractMappingContext.java:487) ~[spring-data-commons-1.13.3.RELEASE.jar:?]
at org.springframework.data.mapping.context.AbstractMappingContext$PersistentPropertyCreator.doWith(AbstractMappingContext.java:465) ~[spring-data-commons-1.13.3.RELEASE.jar:?]
at org.springframework.util.ReflectionUtils.doWithFields(ReflectionUtils.java:693) ~[spring-core-4.3.8.RELEASE.jar:4.3.8.RELEASE]
at org.springframework.data.mapping.context.AbstractMappingContext.addPersistentEntity(AbstractMappingContext.java:329) ~[spring-data-commons-1.13.3.RELEASE.jar:?]
at org.springframework.data.mapping.context.AbstractMappingContext$PersistentPropertyCreator.createAndRegisterProperty(AbstractMappingContext.java:508) ~[spring-data-commons-1.13.3.RELEASE.jar:?]
at org.springframework.data.mapping.context.AbstractMappingContext$PersistentPropertyCreator.doWith(AbstractMappingContext.java:465) ~[spring-data-commons-1.13.3.RELEASE.jar:?]
at org.springframework.util.ReflectionUtils.doWithFields(ReflectionUtils.java:693) ~[spring-core-4.3.8.RELEASE.jar:4.3.8.RELEASE]
at org.springframework.data.mapping.context.AbstractMappingContext.addPersistentEntity(AbstractMappingContext.java:329) ~[spring-data-commons-1.13.3.RELEASE.jar:?]
at org.springframework.data.mapping.context.AbstractMappingContext$PersistentPropertyCreator.createAndRegisterProperty(AbstractMappingContext.java:508) ~[spring-data-commons-1.13.3.RELEASE.jar:?]
at org.springframework.data.mapping.context.AbstractMappingContext$PersistentPropertyCreator.doWith(AbstractMappingContext.java:465) ~[spring-data-common]s-1.13.3.RELEASE.jar:?
我不希望它扫描这个类(或任何类)。我只是删除spring-data-commons
并不成功。因为它在我的应用程序的其他部分中用于注入一些会话对象。
有什么建议可以解决这个问题吗?
P.S:我不是弹簧数据方面的专家。但是已经使用弹簧已经有一段时间了。干杯!