<?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:context= "http://www.springframework.org/schema/context" |
xmlns:mvc= "http://www.springframework.org/schema/mvc" |
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/context |
http: //www.springframework.org/schema/context/spring-context-3.1.xsd |
http: //www.springframework.org/schema/tx |
http: //www.springframework.org/schema/tx/spring-tx-4.0.xsd |
http: //www.springframework.org/schema/mvc |
http: //www.springframework.org/schema/mvc/spring-mvc-4.0.xsd"> |
<!-- 配置数据库相关参数 --> |
<context:property-placeholder location= "classpath:db.properties" /> |
<!-- 配置自动扫描的包 --> |
<context:component-scan base- package = "com.shop.dao" ></context:component-scan> |
<context:component-scan base- package = "com.shop" > |
<context:exclude-filter type= "annotation" expression= "org.springframework.stereotype.Controller" /> |
<context:exclude-filter type= "annotation" expression= "org.springframework.web.bind.annotation.ControllerAdvice" /> |
</context:component-scan> |
<bean id= "dataSource" class = "com.mchange.v2.c3p0.ComboPooledDataSource" > |
<property name= "user" value= "${jdbc.user}" ></property> |
<property name= "password" value= "${jdbc.password}" ></property> |
<property name= "driverClass" value= "${jdbc.driverClass}" ></property> |
<property name= "jdbcUrl" value= "${jdbc.jdbcUrl}" ></property> |
<!-- 配置其他属性 --> |
</bean> |
<!-- 配置SessionFactory --> |
<bean id= "sessionFactory" class = "org.springframework.orm.hibernate4.LocalSessionFactoryBean" > |
<property name= "dataSource" > |
<ref bean= "dataSource" /> |
</property> |
<property name= "hibernateProperties" > |
<props> |
<prop key= "hibernate.dialect" >org.hibernate.dialect.MySQLDialect</prop> |
<prop key= "hibernate.hbm2ddl.auto" >update</prop> |
<prop key= "hibernate.show_sql" > false </prop> |
<prop key= "hibernate.format_sql" > true </prop> |
</props> |
</property> |
<property name= "packagesToScan" > |
<list> |
<value>com.shop.model</value> |
<value>com.shop.dao</value> |
|
</list> |
</property> |
</bean> |
<!-- 配置事务管理器 --> |
<bean id= "transactionManager" class = "org.springframework.orm.hibernate4.HibernateTransactionManager" > |
<property name= "sessionFactory" > |
<ref bean= "sessionFactory" /> |
</property> |
</bean> |
|
<!-- 开启注解事务--> |
<tx:annotation-driven transaction-manager= "transactionManager" /> |
<!-- 配置扫描Dao接口包,动态实现Dao接口并注入spring容器中 --> |
<!-- 使用MapperScannerConfigurer是为了防止提前它初始化qlLSessionFactory,而此时可能properties文件还未加载 --> |
<!--<bean class = "org.mybatis.spring.mapper.MapperScannerConfigurer" > |
<!– 注入sqlSessionFactory –> |
<property name= "sqlSessionFactoryBeanName" value= "sqlSessionFactory" /> |
<!– 给出需要扫描Dao接口包 –> |
<property name= "basePackage" value= "org.seckill.dao" /> |
</bean>--> |
<!-- 自动注册 DefaultAnnotationHandlerMapping 与 AnnotationMethodHandlerAdapter 两个bean, |
是spring MVC为 @Controllers 分发请求所必须的 --> |
<mvc:annotation-driven/> |
</beans> |
初级程序员
by: 一只学编程的球 发表于:2018-07-18 10:27:52 顶(0) | 踩(0) 回复
我在eclipse中运行时碰到了一些错误,不知道怎么解决,连续几个帖子中的都有错误,简直不知道是我eclipse不对还是这些程序不对。
回复评论