サンプルSpring 3.2+Hibernate+Postgres 9.4 を Apache tomcat8 Java-8 Web アプリケーションで実行しています。次のエラーが表示されます:
org.springframework.beans.factory.BeanCreationException: 'employeeDao' という名前の Bean の作成中にエラーが発生しました: 自動配線された依存関係の注入に失敗しました。ネストされた例外は org.springframework.beans.factory.BeanCreationExceptionです: フィールドを自動配線できませんでした: private org.hibernate.SessionFactory com.forum.dao.EmployeeDaoImpl.sessionFactory; ネストされた例外は org.springframework.beans.factory.BeanCreationException: ServletContext リソース [/WEB-INF/spring-servlet.xml] で定義された名前 'sessionFactory' を持つ Bean の作成中にエラーが発生しました: Bean プロパティの設定中に Bean 'dataSource' への参照を解決できません'情報源'; ネストされた例外は org.springframework.beans.factory.BeanCreationException: ServletContext リソース [/WEB-INF/spring-servlet.xml] で定義された 'dataSource' という名前の Bean を作成中にエラーが発生しました: プロパティ値の設定中にエラーが発生しました。ネストされた例外は次のとおりです。org.springframework.beans.PropertyBatchUpdateException; ネストされた PropertyAccessExceptions (1) は次のとおりです。 PropertyAccessException 1: org.springframework.beans. MethodInvocationException: プロパティ 'driverClassName' が例外をスローしました。ネストされた例外は java.lang.UnsupportedClassVersionError: org/postgresql/Driver サポートされていない major.minor バージョン 52.0 (クラス org.postgresql.Driver を読み込めません)
src/resources の database.properties ファイル
database.driver=org.postgresql.Driver
database.url=jdbc:postgresql://localhost:5432/sample
database.user=postgres
database.password=sujata
hibernate.dialect=org.hibernate.dialect.PostgreSQLDialect
hibernate.show_sql=true
hibernate.hbm2ddl.auto=update
spring-servlet.xml
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:mvc="http://www.springframework.org/schema/mvc"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:tx="http://www.springframework.org/schema/tx"
xsi:schemaLocation="
http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context- 3.0.xsd
http://www.springframework.org/schema/mvc
http://www.springframework.org/schema/mvc/spring-mvc-3.0.xsd
http://www.springframework.org/schema/tx
http://www.springframework.org/schema/tx/spring-tx-3.0.xsd">
<context:property-placeholder location="classpath:resources/database.properties" />
<context:component-scan base-package="com.forum" />
<mvc:annotation-driven/>
<tx:annotation-driven transaction- manager="hibernateTransactionManager"/>
<bean id="jspViewResolver"
class="org.springframework.web.servlet.view.InternalResourceViewResolver">
<property name="viewClass"
value="org.springframework.web.servlet.view.JstlView" />
<property name="prefix" value="/WEB-INF/jsp/" />
<property name="suffix" value=".jsp" />
</bean>
<bean id="dataSource"
class="org.springframework.jdbc.datasource.DriverManagerDataSource">
<property name="driverClassName" value="${database.driver}" />
<property name="url" value="${database.url}" />
<property name="username" value="${database.user}" />
<property name="password" value="${database.password}" />
</bean>
<bean id="sessionFactory"
class="org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean">
<property name="dataSource" ref="dataSource" />
<property name="annotatedClasses">
<list>
<value>com.forum.model.Employee</value>
</list>
</property>
<property name="hibernateProperties">
<props>
<prop key="hibernate.dialect">${hibernate.dialect} </prop>
<prop key="hibernate.show_sql">${hibernate.show_sql}</prop>
<prop key="hibernate.hbm2ddl.auto">${hibernate.hbm2ddl.auto}</prop>
</props>
</property>
</bean>
<bean id="hibernateTransactionManager"
class="org.springframework.orm.hibernate3.HibernateTransactionManager">
<property name="sessionFactory" ref="sessionFactory" />
</bean>
利用可能なすべての回答を試しました-JRE、JDKコンプライアンスレベル、postgresバージョンと関連ドライバー、方言名、適切なドライバーを確認しました。しかし、問題は解決しません。また、プログラムは Mysql に対して完全に実行されます。postgresql-9.4-1206-jdbc42.jar を Web Content/WEB-INF/lib/ フォルダーに配置し、Add External Jars を使用してビルド パスに含めませんでした。次の定義で何が間違っていますか?