java - applicationContext.xml 文件有什么问题

标签 java xml web-applications

我正在尝试将 dtatbase 连接到我的 Web 应用程序。 MSSQL 服务器中的数据库。这是我的 applicationContext.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:p="http://www.springframework.org/schema/p"
       xmlns:aop="http://www.springframework.org/schema/aop"
       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.1.xsd
       http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-3.1.xsd
       http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-3.1.xsd">

    <bean id="txManagerDH" class="org.springframework.orm.hibernate3.HibernateTransactionManager">
          <property name="sessionFactory" ref="dhSessionFactory"/>
    </bean>

    <tx:annotation-driven transaction-manager="txManagerDH"/>      

<bean id="dhDataSource"
    class="org.springframework.jdbc.datasource.DriverManagerDataSource"
    p:driverClassName="com.microsoft.sqlserver.jdbc.SQLServerDriver"
    p:url="jdbc:sqlserver://TARAS-PC\SQLEXPRESS:1433:databaseName=DH:"
    p:username="GlassfishDH"
    p:password="glassfish" />

    <bean id="dhSessionFactory"
          class="org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean"
          p:dataSource-ref="dhDataSource">
        <property name="annotatedClasses">
            <list>
                <value>model.User</value>
            </list>
        </property>
        <property name="hibernateProperties">
            <props>
                <prop key="hibernate.dialect">
                    org.hibernate.dialect.SQLServerDialect
                </prop>
                <prop key="hibernate.show_sql">false</prop>
            </props>
        </property>
    </bean>

    <bean id="UserDao" class="model.UserDao" p:sessionFactory-ref="dhSessionFactory"/>

    <bean id="UserService" class="service.UserService"
        p:userDao-ref="UserDao"/>

</beans>

当我尝试运行它时,出现错误:

Error occurred during deployment: Exception while loading the app : java.lang.IllegalStateException: ContainerBase.addChild: start: org.apache.catalina.LifecycleException: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'txManagerDH' defined in ServletContext resource [/WEB-INF/applicationContext.xml]: BeanPostProcessor before instantiation of bean failed; nested exception is java.lang.NoClassDefFoundError: org/aopalliance/aop/Advice. Please see server.log for more details.

我不知道我的代码有什么问题。请帮助我。

最佳答案

您的类路径中缺少 aop-alliance 库。您可以获取二进制文件或maven依赖项here .

或者,获取完整的 spring-aop 库。

关于java - applicationContext.xml 文件有什么问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22284769/

相关文章:

java - 修改 SeaGlass JComponents

XMl 架构 : Unique key values within parent

php - 在我的下一个 Web 应用程序项目中使用 Node.JS 而不是 PHP?

javascript - JavaScript 的 localstorage 字符串存储在哪里?

java - 有人能告诉我为什么这个方法会进入无限循环吗?

java - Spark中通过SWIFT从对象存储获取数据需要什么配置

xml - XSLT 将 xml 转换为 xml 提取特定值并映射到新格式

asp.net - 用户控件渲染: write link to current page?

java - 将 Valo 主题的间距和小部件大小缩小到 Reindeer 主题

java - Eclipse插件开发中的向导分类