如何消除Spring Neo4j启动时的警告?

5

我正在使用Springboot配合Spring Data Neo4j进行开发,应用程序可以正常运行。

但是,启动时会出现一大堆警告信息,如果有可能的话,我希望能够去除这些警告。

2019-09-08 14:15:20.788  WARN 10121 --- [  restartedMain] o.s.d.n.mapping.Neo4jPersistentProperty  : Owning ClassInfo is null for property: org.apache.commons.logging.Log.fatalEnabled
2019-09-08 14:15:20.789  WARN 10121 --- [  restartedMain] o.s.d.n.mapping.Neo4jPersistentProperty  : Owning ClassInfo is null for property: org.apache.commons.logging.Log.errorEnabled
2019-09-08 14:15:20.790  WARN 10121 --- [  restartedMain] o.s.d.n.mapping.Neo4jPersistentProperty  : Owning ClassInfo is null for property: org.apache.commons.logging.Log.infoEnabled
2019-09-08 14:15:20.790  WARN 10121 --- [  restartedMain] o.s.d.n.mapping.Neo4jPersistentProperty  : Owning ClassInfo is null for property: org.apache.commons.logging.Log.debugEnabled
2019-09-08 14:15:20.790  WARN 10121 --- [  restartedMain] o.s.d.n.mapping.Neo4jPersistentProperty  : Owning ClassInfo is null for property: org.apache.commons.logging.Log.traceEnabled
2019-09-08 14:15:20.791  WARN 10121 --- [  restartedMain] o.s.d.n.mapping.Neo4jPersistentProperty  : Owning ClassInfo is null for property: org.apache.commons.logging.Log.warnEnabled
2019-09-08 14:15:20.796  WARN 10121 --- [  restartedMain] o.s.d.n.mapping.Neo4jPersistentProperty  : Owning ClassInfo is null for property: org.springframework.context.ApplicationContext.parent
2019-09-08 14:15:20.796  WARN 10121 --- [  restartedMain] o.s.d.n.mapping.Neo4jPersistentProperty  : Owning ClassInfo is null for property: org.springframework.context.ApplicationContext.environment
2019-09-08 14:15:20.797  WARN 10121 --- [  restartedMain] o.s.d.n.mapping.Neo4jPersistentProperty  : Owning ClassInfo is null for property: org.springframework.context.ApplicationContext.classLoader
2019-09-08 14:15:20.797  WARN 10121 --- [  restartedMain] o.s.d.n.mapping.Neo4jPersistentProperty  : Owning ClassInfo is null for property: org.springframework.context.ApplicationContext.displayName
2019-09-08 14:15:20.797  WARN 10121 --- [  restartedMain] o.s.d.n.mapping.Neo4jPersistentProperty  : Owning ClassInfo is null for property: org.springframework.context.ApplicationContext.startupDate
2019-09-08 14:15:20.798  WARN 10121 --- [  restartedMain] o.s.d.n.mapping.Neo4jPersistentProperty  : Owning ClassInfo is null for property: org.springframework.context.ApplicationContext.beanDefinitionCount
2019-09-08 14:15:20.798  WARN 10121 --- [  restartedMain] o.s.d.n.mapping.Neo4jPersistentProperty  : Owning ClassInfo is null for property: org.springframework.context.ApplicationContext.autowireCapableBeanFactory
2019-09-08 14:15:20.798  WARN 10121 --- [  restartedMain] o.s.d.n.mapping.Neo4jPersistentProperty  : Owning ClassInfo is null for property: org.springframework.context.ApplicationContext.beanDefinitionNames
2019-09-08 14:15:20.799  WARN 10121 --- [  restartedMain] o.s.d.n.mapping.Neo4jPersistentProperty  : Owning ClassInfo is null for property: org.springframework.context.ApplicationContext.parentBeanFactory
2019-09-08 14:15:20.799  WARN 10121 --- [  restartedMain] o.s.d.n.mapping.Neo4jPersistentProperty  : Owning ClassInfo is null for property: org.springframework.context.ApplicationContext.id
2019-09-08 14:15:20.799  WARN 10121 --- [  restartedMain] o.s.d.n.mapping.Neo4jPersistentProperty  : Owning ClassInfo is null for property: org.springframework.context.ApplicationContext.applicationName
2019-09-08 14:15:20.801  INFO 10121 --- [  restartedMain] o.s.d.neo4j.mapping.Neo4jMappingContext  : No class information found in OGM meta-data for class org.springframework.security.config.annotation.authentication.configuration.AuthenticationConfiguration so treating as simple type for SD Commons
2019-09-08 14:15:20.802  INFO 10121 --- [  restartedMain] o.s.d.neo4j.mapping.Neo4jMappingContext  : No class information found in OGM meta-data for class org.springframework.security.config.annotation.authentication.builders.AuthenticationManagerBuilder so treating as simple type for SD Commons
2019-09-08 14:15:20.805  INFO 10121 --- [  restartedMain] o.s.d.neo4j.mapping.Neo4jMappingContext  : No class information found in OGM meta-data for class org.springframework.security.config.annotation.web.builders.HttpSecurity so treating as simple type for SD Commons
2019-09-08 14:15:20.850  INFO 10121 --- [  restartedMain] o.s.d.neo4j.mapping.Neo4jMappingContext  : No class information found in OGM meta-data for class java.util.ArrayList so treating as simple type for SD Commons
2019-09-08 14:15:20.896  INFO 10121 --- [  restartedMain] o.s.d.neo4j.mapping.Neo4jMappingContext  : No class information found in OGM meta-data for class org.springframework.http.HttpHeaders so treating as simple type for SD Commons
2019-09-08 14:15:20.929  WARN 10121 --- [  restartedMain] o.s.d.n.mapping.Neo4jPersistentProperty  : Owning ClassInfo is null for property: org.springframework.core.env.Environment.defaultProfiles
2019-09-08 14:15:20.929  WARN 10121 --- [  restartedMain] o.s.d.n.mapping.Neo4jPersistentProperty  : Owning ClassInfo is null for property: org.springframework.core.env.Environment.activeProfiles
2019-09-08 14:15:20.932  WARN 10121 --- [  restartedMain] o.s.d.n.mapping.Neo4jPersistentProperty  : Owning ClassInfo is null for property: javax.servlet.ServletContext.initParameterNames
2019-09-08 14:15:20.932  WARN 10121 --- [  restartedMain] o.s.d.n.mapping.Neo4jPersistentProperty  : Owning ClassInfo is null for property: javax.servlet.ServletContext.virtualServerName
2019-09-08 14:15:20.932  WARN 10121 --- [  restartedMain] o.s.d.n.mapping.Neo4jPersistentProperty  : Owning ClassInfo is null for property: javax.servlet.ServletContext.classLoader
2019-09-08 14:15:20.932  WARN 10121 --- [  restartedMain] o.s.d.n.mapping.Neo4jPersistentProperty  : Owning ClassInfo is null for property: javax.servlet.ServletContext.filterRegistrations
2019-09-08 14:15:20.933  WARN 10121 --- [  restartedMain] o.s.d.n.mapping.Neo4jPersistentProperty  : Owning ClassInfo is null for property: javax.servlet.ServletContext.servletNames
2019-09-08 14:15:20.933  WARN 10121 --- [  restartedMain] o.s.d.n.mapping.Neo4jPersistentProperty  : Owning ClassInfo is null for property: javax.servlet.ServletContext.sessionTrackingModes
2019-09-08 14:15:20.933  WARN 10121 --- [  restartedMain] o.s.d.n.mapping.Neo4jPersistentProperty  : Owning ClassInfo is null for property: javax.servlet.ServletContext.contextPath
2019-09-08 14:15:20.933  WARN 10121 --- [  restartedMain] o.s.d.n.mapping.Neo4jPersistentProperty  : Owning ClassInfo is null for property: javax.servlet.ServletContext.defaultSessionTrackingModes
2019-09-08 14:15:20.934  WARN 10121 --- [  restartedMain] o.s.d.n.mapping.Neo4jPersistentProperty  : Owning ClassInfo is null for property: javax.servlet.ServletContext.majorVersion
2019-09-08 14:15:20.934  WARN 10121 --- [  restartedMain] o.s.d.n.mapping.Neo4jPersistentProperty  : Owning ClassInfo is null for property: javax.servlet.ServletContext.effectiveMinorVersion
2019-09-08 14:15:20.934  WARN 10121 --- [  restartedMain] o.s.d.n.mapping.Neo4jPersistentProperty  : Owning ClassInfo is null for property: javax.servlet.ServletContext.sessionCookieConfig
2019-09-08 14:15:20.934  WARN 10121 --- [  restartedMain] o.s.d.n.mapping.Neo4jPersistentProperty  : Owning ClassInfo is null for property: javax.servlet.ServletContext.effectiveSessionTrackingModes
2019-09-08 14:15:20.934  WARN 10121 --- [  restartedMain] o.s.d.n.mapping.Neo4jPersistentProperty  : Owning ClassInfo is null for property: javax.servlet.ServletContext.attributeNames
2019-09-08 14:15:20.935  WARN 10121 --- [  restartedMain] o.s.d.n.mapping.Neo4jPersistentProperty  : Owning ClassInfo is null for property: javax.servlet.ServletContext.serverInfo
2019-09-08 14:15:20.935  WARN 10121 --- [  restartedMain] o.s.d.n.mapping.Neo4jPersistentProperty  : Owning ClassInfo is null for property: javax.servlet.ServletContext.servletRegistrations
2019-09-08 14:15:20.935  WARN 10121 --- [  restartedMain] o.s.d.n.mapping.Neo4jPersistentProperty  : Owning ClassInfo is null for property: javax.servlet.ServletContext.jspConfigDescriptor
2019-09-08 14:15:20.935  WARN 10121 --- [  restartedMain] o.s.d.n.mapping.Neo4jPersistentProperty  : Owning ClassInfo is null for property: javax.servlet.ServletContext.servlets
2019-09-08 14:15:20.936  WARN 10121 --- [  restartedMain] o.s.d.n.mapping.Neo4jPersistentProperty  : Owning ClassInfo is null for property: javax.servlet.ServletContext.requestCharacterEncoding
2019-09-08 14:15:20.936  WARN 10121 --- [  restartedMain] o.s.d.n.mapping.Neo4jPersistentProperty  : Owning ClassInfo is null for property: javax.servlet.ServletContext.responseCharacterEncoding
2019-09-08 14:15:20.936  WARN 10121 --- [  restartedMain] o.s.d.n.mapping.Neo4jPersistentProperty  : Owning ClassInfo is null for property: javax.servlet.ServletContext.sessionTimeout
2019-09-08 14:15:20.936  WARN 10121 --- [  restartedMain] o.s.d.n.mapping.Neo4jPersistentProperty  : Owning ClassInfo is null for property: javax.servlet.ServletContext.minorVersion
2019-09-08 14:15:20.937  WARN 10121 --- [  restartedMain] o.s.d.n.mapping.Neo4jPersistentProperty  : Owning ClassInfo is null for property: javax.servlet.ServletContext.servletContextName
2019-09-08 14:15:20.937  WARN 10121 --- [  restartedMain] o.s.d.n.mapping.Neo4jPersistentProperty  : Owning ClassInfo is null for property: javax.servlet.ServletContext.effectiveMajorVersion
2019-09-08 14:15:20.938  WARN 10121 --- [  restartedMain] o.s.d.n.mapping.Neo4jPersistentProperty  : Owning ClassInfo is null for property: javax.servlet.FilterConfig.initParameterNames
2019-09-08 14:15:20.938  WARN 10121 --- [  restartedMain] o.s.d.n.mapping.Neo4jPersistentProperty  : Owning ClassInfo is null for property: javax.servlet.FilterConfig.servletContext
2019-09-08 14:15:20.939  WARN 10121 --- [  restartedMain] o.s.d.n.mapping.Neo4jPersistentProperty  : Owning ClassInfo is null for property: javax.servlet.FilterConfig.filterName

什么导致它如此不开心?

你最终解决了这个问题吗? - SledgeHammer
不好意思,我目前只是在过滤它们 :( - GreenAsJade
实际上,我最终解决了它... :)。我会发布一个答案... - SledgeHammer
3个回答

4

我遇到了同样的问题,经过两天的摸索,终于找到了解决方法...

我的 pom.xml 文件如下:

    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-data-neo4j</artifactId>
        <version>2.2.2.RELEASE</version> <!--$NO-MVN-MAN-VER$-->
    </dependency>

通常情况下,您的应用程序属性中会包含用户名和密码:
spring.data.neo4j.open-in-view=false
spring.data.neo4j.uri=bolt://localhost
spring.data.neo4j.username=neo4j
spring.data.neo4j.password=xxx

你还需要使用以下方法:

@EnableNeo4jRepositories

Neo4j代码似乎默认扫描你的应用程序中的所有类,但你可以覆盖此行为:

  1. 创建一个配置类并将@EnableNeo4jRepositories移动到其中。
  2. 指定你的仓库基础包.
  3. 指定你的模型基础包.

现在,Neo4j代码知道只扫描repo和model包。 这是我针对电影数据集的配置类:

@Configuration
@EnableNeo4jRepositories(basePackages="org.xx.yy.movies.repositories")
public class MoviesDataSourceConfig {

    @Bean
    public org.neo4j.ogm.config.Configuration getConfiguration() {
        org.neo4j.ogm.config.Configuration config = new Builder()
                .uri("bolt://username:password@localhost:7687").
                build();
        return config;
    }

    @Bean
    public Neo4jTransactionManager transactionManager() {
        return new Neo4jTransactionManager(sessionFactory());
    }

    @Bean
    public SessionFactory sessionFactory() {
        return new SessionFactory(getConfiguration(), "org.xx.yy.movies.models");
    }
}

请注意,您需要在URI中指定用户名和密码... 这仍然是POC代码,但我将从spring.data.neo4j属性中提取它们以进行生产。

不再有警告信息!


3

我也遇到了同样的问题(使用SpringBoot 2.2.2以及依赖spring-boot-starter-data-neo4j)。我通过在主应用类上添加两个注释来消除这个警告,缩小了对实体/模型类的扫描范围:@SpringBootApplication

@EnableNeo4jRepositories("my.project.reposoitory")
@EntityScan("my.project.model")

避免需要单独的@Config类/重写SpringBoot自动配置。请参阅文档更新: 将Spring Boot版本提升到2.2.4.RELEASE,因为我在使用Neo4jRepository声明方法时遇到了无法返回任何数据的问题。怀疑这与事务相关,将提出缺陷报告。

我已经按照一些设置教程使用了 @EnableNeo4jRepositories。再加上 @EntityScan,这样就解决了我的错误。 - Graham Lea

-1

我解决这个错误的最简单方法是在application.properties文件中添加以下行:

logging.level.org.spring.data.neo4j.mapping.*=ERROR


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接