马上注册,结交更多好友,享用更多功能^_^
您需要 登录 才可以下载或查看,没有账号?立即注册
x
错误信息:java.lang.ClassNotFoundException: com.jdbc.mysql.Driver<?xml version="1.0" encoding="UTF-8"?>
测试时可以操作数据库,但启动tomcat就是一堆错
applicationContext.xml的配置
<beans xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:aop="http://www.springframework.org/schema/aop" xmlns="http://www.springframework.org/schema/beans" xmlns:context="http://www.springframework.org/schema/context" xmlns:tx="http://www.springframework.org/schema/tx" xsi:schemaLocation="http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-4.2.xsd http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-4.2.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-4.2.xsd http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-4.2.xsd ">
<!-- 将sessionfactory配置到spring中 -->
<!-- 加载配置方案一:使用外部的hibernate.cfg.xml配置 -->
<!-- <bean name="sessionFactory" class="org.springframework.orm.hibernate5.LocalSessionFactoryBean">
<property name="configLocation" value="classpath:hibernate.cfg.xml"></property>
</bean> -->
<!-- 读取配置文件 -->
<context:property-placeholder location="classpath:db.properties"/>
<!-- 配置c3p0连接池 -->
<bean name="dataSource" class="com.mchange.v2.c3p0.ComboPooledDataSource">
<property name="driverClass" value="${jdbc.driverClass}"></property>
<property name="jdbcUrl" value="${jdbc.jdbcUrl}"></property>
<property name="user" value="${jdbc.user}"></property>
<property name="password" value="${jdbc.password}"></property>
</bean>
<!-- 配置核心事物管理器 -->
<bean name="transactionManager" class="org.springframework.orm.hibernate5.HibernateTransactionManager">
<property name="sessionFactory" ref="sessionFactory"></property>
</bean>
<bean name="sessionFactory" class="org.springframework.orm.hibernate5.LocalSessionFactoryBean">
<!-- 将连接池注入到sessionfactory,hibernate会自动从连接池获取连接 -->
<property name="dataSource" ref="dataSource"></property>
<!-- 配置hibernate基本信息 -->
<property name="hibernateProperties">
<props>
<!-- 必选配置
<prop key="hibernate.connection.driver_class">com.mysql.jdbc.Driver</prop>
<prop key="hibernate.connection.url">jdbc:mysql:///crm</prop>
<prop key="hibernate.connection.username">root</prop>
<prop key="hibernate.connection.password">123</prop> -->
<prop key="hibernate.dialect">org.hibernate.dialect.MySQLDialect</prop>
<!--可选配置-->
<prop key="hibernate.show_sql">true</prop>
<prop key="hibernate.format_sql">true</prop>
<prop key="hibernate.hbm2ddl.auto">update</prop>
</props>
</property>
<!-- 引入orm元数据,指定orm元数据所在的包的路径,spring会自动读取包下的所有配置 -->
<property name="mappingLocations">
<value>classpath:/com/tedu/domain/*.hbm.xml</value>
</property>
</bean>
<!-- 配置事务通知 -->
<!-- <tx:advice id="txAdvice" transaction-manager="transactionManager">
<tx:attributes>
以方法为单位,指定方法应用什么事务属性
isolation:隔离级别
propagation:传播行为
read-only:是否只读
<tx:method name="save*" isolation="REPEATABLE_READ" propagation="REQUIRED" read-only="false"/>
<tx:method name="persist*" isolation="REPEATABLE_READ" propagation="REQUIRED" read-only="false"/>
<tx:method name="update*" isolation="REPEATABLE_READ" propagation="REQUIRED" read-only="false"/>
<tx:method name="modify*" isolation="REPEATABLE_READ" propagation="REQUIRED" read-only="false"/>
<tx:method name="delete*" isolation="REPEATABLE_READ" propagation="REQUIRED" read-only="false"/>
<tx:method name="remove*" isolation="REPEATABLE_READ" propagation="REQUIRED" read-only="false"/>
<tx:method name="get*" isolation="REPEATABLE_READ" propagation="REQUIRED" read-only="true"/>
<tx:method name="find*" isolation="REPEATABLE_READ" propagation="REQUIRED" read-only="true"/>
</tx:attributes>
</tx:advice> -->
<!-- 配置织入 -->
<!-- <aop:config>
配置切入点表达式
<aop:pointcut expression="execution(* com.tedu.service.impl.*ServiceImpl.*(..))" id="txPc"></aop:pointcut>
配置切面:通知+切点
advice-ref:通知的名称
pointcut-ref:切点的名称
<aop:advisor advice-ref="txAdvice" pointcut-ref="txPc"/>
</aop:config> -->
<!-- 开启注解事物 -->
<tx:annotation-driven transaction-manager="transactionManager"/>
<!-- action
Action的作用范围一定是多例的,这样才符合Struts2架构
-->
<bean name="userAction" class="com.tedu.web.action.UserAction" scope="prototype">
<property name="userService" ref="userService"></property>
</bean>
<!-- service -->
<bean name="userService" class="com.tedu.service.impl.UserServiceImpl" >
<property name="userDao" ref="userDao"></property>
</bean>
<!-- dao -->
<bean name="userDao" class="com.tedu.dao.impl.UserDaoImpl">
<property name="sessionFactory" ref="sessionFactory"></property>
</bean>
</beans>
|