如何摆脱Spring Neo4j启动警告?

时间:2019-09-08 04:50:07

标签: spring-boot neo4j spring-data-neo4j

我在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

是什么让它如此不开心?

3 个答案:

答案 0 :(得分:3)

我遇到了同样的问题,两天后,我终于明白了...

我的pom.xml看起来像这样:

spring.data.neo4j.open-in-view=false
spring.data.neo4j.uri=bolt://localhost
spring.data.neo4j.username=neo4j
spring.data.neo4j.password=xxx

通常,您将在应用程序属性中拥有用户名和密码:

@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");
    }
}

您还将获得启用呼叫:

@ EnableNeo4jRepositories

默认情况下,似乎Neo4j代码正在扫描应用程序中的所有类,但是您可以覆盖此行为:

  1. 创建一个配置类并将您的EnableNeo4jRepositories移到那里
  2. 指定您的回购基本软件包
  3. 指定您的模型基本包装

现在Neo4j代码知道只扫描回购和模型包。这是我的Movie数据集的配置类:

dirname=$1
files=$(ls $dirname)

for file in $files
do
wc -c $file
done

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

没有更多警告消息!

答案 1 :(得分:2)

有同样的问题(依赖项为spring-boot-starter-data-neo4j的SpringBoot 2.2.2)。通过在主要的@SpringBootApplication带注释的应用程序类中添加 both 注释,摆脱了警告/缩小了对实体/模型类的扫描范围:

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

避免需要单独的@Config类/替代SpringBoot自动配置。请参见docs

更新: 由于我在从2.2.4.RELEASE声明式方法返回任何数据时遇到问题,因此将Spring Boot版本更改为Neo4jRepository。怀疑这与tx有关,将引发缺陷。

答案 2 :(得分:-1)

我为我的应用程序解决此错误的最简单方法是在application.properties文件中添加以下行

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