日志中的错误版本:INFO org.hibernate.cfg.Environment
Posted
技术标签:
【中文标题】日志中的错误版本:INFO org.hibernate.cfg.Environment【英文标题】:WRONG VERSION in log: INFO org.hibernate.cfg.Environment 【发布时间】:2014-02-08 22:17:48 【问题描述】:我在加载休眠版本 jar 时遇到问题....eclipse 日志显示我使用的是 3.2.4.sp1,但在我的 pom.xml 中我使用的是 4.2.0.Final。所以我想这就是我得到异常的原因......
信息:org.springframework.beans.factory.xml.XmlBeanDefinitionReader - 从类路径资源 [root-context.xml] 加载 XML bean 定义 信息:org.springframework.context.annotation.ClassPathBeanDefinitionScanner - JSR-250 'javax.annotation.ManagedBean' 找到并支持组件扫描 信息:org.springframework.context.annotation.ClassPathBeanDefinitionScanner - JSR-330 'javax.inject.Named' 注释找到并支持组件扫描 信息:org.springframework.beans.factory.xml.XmlBeanDefinitionReader - 从类路径资源 [root-context.xml] 加载 XML bean 定义 信息:org.springframework.context.annotation.ClassPathBeanDefinitionScanner - JSR-250 'javax.annotation.ManagedBean' 找到并支持组件扫描 信息:org.springframework.context.annotation.ClassPathBeanDefinitionScanner - JSR-330 'javax.inject.Named' 注释找到并支持组件扫描 信息:org.springframework.beans.factory.support.DefaultListableBeanFactory - 覆盖 bean 'jdbcTemplate' 的 bean 定义:替换 [Generic bean: class [org.springframework.jdbc.core.simple.SimpleJdbcTemplate];范围=;摘要=假;懒惰初始化=假;自动线模式=0;依赖检查=0;自动接线候选=真;主要=假;工厂BeanName=空;工厂方法名=空;初始化方法名=空;销毁方法名=空;在类路径资源 [root-context.xml]] 中使用 [Generic bean: class [org.springframework.jdbc.core.simple.SimpleJdbcTemplate] 定义;范围=;摘要=假;懒惰初始化=假;自动线模式=0;依赖检查=0;自动接线候选=真;主要=假;工厂BeanName=空;工厂方法名=空;初始化方法名=空;销毁方法名=空;在类路径资源 [root-context.xml] 中定义 信息:org.springframework.beans.factory.support.DefaultListableBeanFactory - 覆盖 bean 'dataSource' 的 bean 定义:替换 [Generic bean: class [org.springframework.jdbc.datasource.DriverManagerDataSource];范围=;摘要=假;懒惰初始化=假;自动线模式=0;依赖检查=0;自动接线候选=真;主要=假;工厂BeanName=空;工厂方法名=空;初始化方法名=空;销毁方法名=空;在类路径资源 [root-context.xml]] 中使用 [Generic bean: class [org.springframework.jdbc.datasource.DriverManagerDataSource] 定义;范围=;摘要=假;懒惰初始化=假;自动线模式=0;依赖检查=0;自动接线候选=真;主要=假;工厂BeanName=空;工厂方法名=空;初始化方法名=空;销毁方法名=空;在类路径资源 [root-context.xml] 中定义 信息:org.springframework.beans.factory.support.DefaultListableBeanFactory - 覆盖bean'sessionFactory'的bean定义:替换[通用bean:类[org.springframework.orm.hibernate4.LocalSessionFactoryBean];范围=;摘要=假;懒惰初始化=假;自动线模式=0;依赖检查=0;自动接线候选=真;主要=假;工厂BeanName=空;工厂方法名=空;初始化方法名=空;销毁方法名=空;在类路径资源 [root-context.xml]] 中使用 [Generic bean: class [org.springframework.orm.hibernate4.LocalSessionFactoryBean] 定义;范围=;摘要=假;懒惰初始化=假;自动线模式=0;依赖检查=0;自动接线候选=真;主要=假;工厂BeanName=空;工厂方法名=空;初始化方法名=空;销毁方法名=空;在类路径资源 [root-context.xml] 中定义 信息:org.springframework.beans.factory.support.DefaultListableBeanFactory - 覆盖bean'transactionManager'的bean定义:替换[通用bean:类[org.springframework.orm.hibernate4.HibernateTransactionManager];范围=;摘要=假;懒惰初始化=假;自动线模式=0;依赖检查=0;自动接线候选=真;主要=假;工厂BeanName=空;工厂方法名=空;初始化方法名=空;销毁方法名=空;在类路径资源 [root-context.xml]] 中使用 [Generic bean: class [org.springframework.orm.hibernate4.HibernateTransactionManager] 定义;范围=;摘要=假;懒惰初始化=假;自动线模式=0;依赖检查=0;自动接线候选=真;主要=假;工厂BeanName=空;工厂方法名=空;初始化方法名=空;销毁方法名=空;在类路径资源 [root-context.xml] 中定义 信息:org.springframework.context.support.GenericApplicationContext - 刷新 org.springframework.context.support.GenericApplicationContext@8916a2:启动日期 [Sun Jan 19 17:55:32 BRST 2014];上下文层次的根 信息:org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor - JSR-330 'javax.inject.Inject' 发现并支持自动装配注释 信息:org.springframework.beans.factory.support.DefaultListableBeanFactory - 在 org.springframework.beans.factory.support.DefaultListableBeanFactory@1e58cb8 中预实例化单例:定义 bean [org.springframework.aop.config.internalAutoProxyCreator,org.springframework. transaction.annotation.AnnotationTransactionAttributeSource#0,org.springframework.transaction.interceptor.TransactionInterceptor#0,org.springframework.transaction.config.internalTransactionAdvisor,org.springframework.context.annotation.internalConfigurationAnnotationProcessor,org.springframework.context.annotation.internalAutowiredAnnotationProcessor, org.springframework.context.annotation.internalRequiredAnnotationProcessor,org.springframework.context.annotation.internalCommonAnnotationProcessor,org.springframework.context.annotation.internalPersistenceAnnotationProcessor,employeeDao,managerDao,taskDao,timesheetDao,entityGenerator,cartService,timesheetService,jdbcTemplate,dataSource,sessionFactory,交易马nager,org.springframework.context.annotation.ConfigurationClassPostProcessor.importAwareProcessor];工厂层次结构的根 信息:org.springframework.jdbc.datasource.DriverManagerDataSource - 加载的 JDBC 驱动程序:com.mysql.jdbc.jdbc2.optional.MysqlDataSource 信息:org.hibernate.cfg.Environment - Hibernate 3.2.4.sp1 信息:org.hibernate.cfg.Environment - hibernate.properties 未找到 信息:org.hibernate.cfg.Environment - 字节码提供者名称:cglib 信息:org.hibernate.cfg.Environment - 使用 JDK 1.4 java.sql.Timestamp 处理 信息:org.springframework.beans.factory.support.DefaultListableBeanFactory - 破坏 org.springframework.beans.factory.support.DefaultListableBeanFactory@1e58cb8 中的单例:定义 bean [org.springframework.aop.config.internalAutoProxyCreator,org.springframework.transaction. annotation.AnnotationTransactionAttributeSource#0,org.springframework.transaction.interceptor.TransactionInterceptor#0,org.springframework.transaction.config.internalTransactionAdvisor,org.springframework.context.annotation.internalConfigurationAnnotationProcessor,org.springframework.context.annotation.internalAutowiredAnnotationProcessor,org. springframework.context.annotation.internalRequiredAnnotationProcessor,org.springframework.context.annotation.internalCommonAnnotationProcessor,org.springframework.context.annotation.internalPersistenceAnnotationProcessor,employeeDao,managerDao,taskDao,timesheetDao,entityGenerator,cartService,timesheetService,jdbcTemplate,dataSource,sessionFactory,transactionManager, ○ rg.springframework.context.annotation.ConfigurationClassPostProcessor.importAwareProcessor];工厂层次结构的根 错误:org.springframework.test.context.TestContextManager - 在允许 TestExecutionListener [org.springframework.test.context.support.DependencyInjectionTestExecutionListener@1554d32] 准备测试实例时捕获异常 [bch.com.br.test.dao.EmployeeDaoTest@13f136e ] java.lang.IllegalStateException:无法加载 ApplicationContext 在 org.springframework.test.context.TestContext.getApplicationContext(TestContext.java:157) ... 原因:org.springframework.beans.factory.BeanCreationException:创建类路径资源[root-context.xml]中定义的名称为“sessionFactory”的bean时出错:调用init方法失败;嵌套异常是 java.lang.NoSuchMethodError: org.springframework.orm.hibernate4.LocalSessionFactoryBuilder.addAnnotatedClass(Ljava/lang/Class;)Lorg/hibernate/cfg/Configuration; 在 org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1486) 在 org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:524) 在 org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:461) 在 org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:295) 在 org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:223) 在 org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:292) 在 org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:194) 在 org.springframework.beans.factory.support.DefaultListableBeanFactory.findAutowireCandidates(DefaultListableBeanFactory.java:891) 在 org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:834) 在 org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:749) 在 org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredMethodElement.inject(AutowiredAnnotationBeanPostProcessor.java:558) ... 42 更多 引起:java.lang.NoSuchMethodError: org.springframework.orm.hibernate4.LocalSessionFactoryBuilder.addAnnotatedClass(Ljava/lang/Class;)Lorg/hibernate/cfg/Configuration; 在 org.springframework.orm.hibernate4.LocalSessionFactoryBuilder.addAnnotatedClasses(LocalSessionFactoryBuilder.java:163) 在 org.springframework.orm.hibernate4.LocalSessionFactoryBuilder.scanPackages(LocalSessionFactoryBuilder.java:198) 在 org.springframework.orm.hibernate4.LocalSessionFactoryBean.afterPropertiesSet(LocalSessionFactoryBean.java:348) 在 org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1545) 在 org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1483) ... 52 更多pom.xml
<properties>
<java-version>1.6</java-version>
<org.springframework-version>3.2.1.RELEASE</org.springframework-version>
<org.aspectj-version>1.6.10</org.aspectj-version>
<org.slf4j-version>1.6.6</org.slf4j-version>
<org.hibernate-version>4.2.0.Final</org.hibernate-version>
</properties>
<dependencies>
<!-- Spring -->
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-context</artifactId>
<version>$org.springframework-version</version>
<exclusions>
<!-- Exclude Commons Logging in favor of SLF4j -->
<exclusion>
<groupId>commons-logging</groupId>
<artifactId>commons-logging</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-webmvc</artifactId>
<version>$org.springframework-version</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-test</artifactId>
<version>$org.springframework-version</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-jdbc</artifactId>
<version>$org.springframework-version</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-orm</artifactId>
<version>$org.springframework-version</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-web</artifactId>
<version>$org.springframework-version</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-aop</artifactId>
<version>$org.springframework-version</version>
</dependency>
<!-- AspectJ -->
<dependency>
<groupId>org.aspectj</groupId>
<artifactId>aspectjrt</artifactId>
<version>$org.aspectj-version</version>
</dependency>
<dependency>
<groupId>org.aspectj</groupId>
<artifactId>aspectjtools</artifactId>
<version>$org.aspectj-version</version>
</dependency>
<!-- Logging -->
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<version>$org.slf4j-version</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>jcl-over-slf4j</artifactId>
<version>$org.slf4j-version</version>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-log4j12</artifactId>
<version>$org.slf4j-version</version>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
<version>1.2.17</version>
<exclusions>
<exclusion>
<groupId>javax.mail</groupId>
<artifactId>mail</artifactId>
</exclusion>
<exclusion>
<groupId>javax.jms</groupId>
<artifactId>jms</artifactId>
</exclusion>
<exclusion>
<groupId>com.sun.jdmk</groupId>
<artifactId>jmxtools</artifactId>
</exclusion>
<exclusion>
<groupId>com.sun.jmx</groupId>
<artifactId>jmxri</artifactId>
</exclusion>
</exclusions>
<scope>runtime</scope>
</dependency>
<!-- @Inject -->
<dependency>
<groupId>javax.inject</groupId>
<artifactId>javax.inject</artifactId>
<version>1</version>
</dependency>
<!-- Servlet -->
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>servlet-api</artifactId>
<version>2.5</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>javax.servlet.jsp</groupId>
<artifactId>jsp-api</artifactId>
<version>2.1</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>jstl</artifactId>
<version>1.2</version>
</dependency>
<!-- Test -->
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.10</version>
</dependency>
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-all</artifactId>
<version>1.9.0</version>
</dependency>
<!-- View -->
<dependency>
<groupId>org.springframework.webflow</groupId>
<artifactId>spring-webflow</artifactId>
<version>2.3.2.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework.webflow</groupId>
<artifactId>spring-js</artifactId>
<version>2.3.2.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-tx</artifactId>
<version>$org.springframework-version</version>
</dependency>
<dependency>
<groupId>ognl</groupId>
<artifactId>ognl</artifactId>
<version>2.6.9</version>
</dependency>
<dependency>
<groupId>opensymphony</groupId>
<artifactId>sitemesh</artifactId>
<version>2.3</version>
</dependency>
<dependency>
<groupId>cglib</groupId>
<artifactId>cglib-nodep</artifactId>
<version>2.1_3</version>
</dependency>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-validator</artifactId>
<version>$org.hibernate-version</version>
</dependency>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-core</artifactId>
<version>$org.hibernate-version</version>
</dependency>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>5.1.6</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<artifactId>maven-eclipse-plugin</artifactId>
<version>2.9</version>
<configuration>
<additionalProjectnatures>
<projectnature>org.springframework.ide.eclipse.core.springnature</projectnature>
</additionalProjectnatures>
<additionalBuildcommands>
<buildcommand>org.springframework.ide.eclipse.core.springbuilder</buildcommand>
</additionalBuildcommands>
<downloadSources>true</downloadSources>
<downloadJavadocs>true</downloadJavadocs>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.5.1</version>
<configuration>
<source>1.6</source>
<target>1.6</target>
<compilerArgument>-Xlint:all</compilerArgument>
<showWarnings>true</showWarnings>
<showDeprecation>true</showDeprecation>
</configuration>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<version>1.2.1</version>
<configuration>
<mainClass>org.test.int1.Main</mainClass>
</configuration>
</plugin>
<plugin>
<artifactId>maven-war-plugin</artifactId>
<version>2.3</version>
<configuration>
<warName>MySpringMVCCart</warName>
<warSourceDirectory>$basedir/src/main/webapp</warSourceDirectory>
<outputDirectory>C:\jboss-as-7.1.1.Final\standalone\deployments</outputDirectory>
<failOnMissingWebXml>false</failOnMissingWebXml>
</configuration>
</plugin>
</plugins>
</build>
</project>
有什么想法吗?
【问题讨论】:
您的项目构建路径中是否可能包含另一个版本的 Spring? 【参考方案1】:-
您是否尝试过在 Eclipse 中清理项目? (项目>清洁...)
您也可以尝试删除 /home/YOUR_USERNAME/.m2/repository/org/hibernate 文件夹。在下一次 mvn 运行期间,您将在终端中看到 hibernate 将下载 hiibernate 的依赖项 - 尝试观察何时下载 3.2.4.sp1。
希望对你有帮助!
【讨论】:
【参考方案2】:您是否在项目的构建路径中添加了另一个 Eclipse 项目? 我有一个类似的问题,结果是:
我添加了另一个使用麻烦的 Hibernate 版本的 Eclipse 项目 由于 Maven 没有跟踪其他项目(它不在我的 pom.xml 中,只是直接添加到构建路径中),因此两个版本的 Hibernate 都在进入类路径 JVM(出于我不明白的原因)从内部项目中选择了 Hibernate 的版本因此,请尝试从其他项目中删除错误版本的 Hibernate,或者只是构建并发布它,以便 Maven 可以在 pom 中为您跟踪其依赖关系。
【讨论】:
以上是关于日志中的错误版本:INFO org.hibernate.cfg.Environment的主要内容,如果未能解决你的问题,请参考以下文章
Info.plist 上传错误中的 CFBundleVersion
centos7web服务器如何设置核心模块core的错误日志为info级别?