2

我用 servlet 在 eclipse 中创建了一个简单的 Dynamic 项目,并试图让 hibernate 使用它

           protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
    PrintWriter out = response.getWriter();
    out.println("Hello World");
    getIntravues();
}

/**
 * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
 */
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
    // TODO Auto-generated method stub
}

private ArrayList<String> getIntravues() {
    // this method will use hibernate to get the names of intravues and their ip addresses
    ArrayList<String> list = new ArrayList<String>();

    Intravue intravue = new Intravue();
    intravue.setIvid(11);
    intravue.setName("hibernate tes");
    ApplicationContext ctx = new ClassPathXmlApplicationContext("applicationContext.xml");
    QueriesClass queriesClass = (QueriesClass) ctx.getBean("TestThree");
    queriesClass.saveInterVue(intravue);
}

我的 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"
xsi:schemaLocation="http://www.springframework.org/schema/beans
    http://www.springframework.org/schema/beans/spring-beans-2.0.xsd"
default-lazy-init="true">

<!-- Datasource for LOCAL database connection -->

<bean id="dataSource"
    class="org.springframework.jdbc.datasource.DriverManagerDataSource">
    <property name="driverClassName" value="com.mysql.jdbc.Driver" />
    <property name="url" value="jdbc:mysql://localhost:3306/dashboardsupervisor" />
    <property name="username" value="root" />
    <property name="password" value="0502" />
</bean>


<bean id="sessionFactory"
    class="org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean">
    <property name="dataSource" ref="dataSource" />
    <property name="annotatedClasses">
        <list>

            <value>svr.Intravue</value>

        </list>
    </property>
</bean>
<bean id="TestThree" class="svr.QueriesClass">
    <property name="sessionFactory" ref="sessionFactory" />
</bean>

我的构建路径

在此处输入图像描述

我的 Tomcat 构建路径

在此处输入图像描述

错误是:

               nested exception is org.springframework.beans.BeanInstantiationException: Could not instantiate bean class [org.hibernate.cfg.AnnotationConfiguration]: Constructor threw exception; nested exception is java.lang.ExceptionInInitializerError
4

0 回答 0