更新 'project2/src/main/resources/applicationContext.xml'
This commit is contained in:
parent
dac59b9ff0
commit
a20345b645
@ -1,6 +1,32 @@
|
||||
<?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.xsd">
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xmlns:context="http://www.springframework.org/schema/context"
|
||||
xsi:schemaLocation="
|
||||
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
|
||||
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd">
|
||||
|
||||
</beans>
|
||||
<!-- 开启注解扫描 -->
|
||||
<context:component-scan base-package="com.example" />
|
||||
|
||||
<!-- 配置数据源 -->
|
||||
<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/mydatabase" />
|
||||
<property name="username" value="root" />
|
||||
<property name="password" value="password" />
|
||||
</bean>
|
||||
|
||||
<!-- 配置MyBatis的SqlSessionFactory -->
|
||||
<bean id="sqlSessionFactory" class="org.mybatis.spring.SqlSessionFactoryBean">
|
||||
<property name="dataSource" ref="dataSource" />
|
||||
<property name="configLocation" value="classpath:mybatis-config.xml" />
|
||||
</bean>
|
||||
|
||||
<!-- 配置MyBatis的Mapper扫描路径 -->
|
||||
<bean class="org.mybatis.spring.mapper.MapperScannerConfigurer">
|
||||
<property name="basePackage" value="com.example.mapper" />
|
||||
<property name="sqlSessionFactoryBeanName" value="sqlSessionFactory" />
|
||||
</bean>
|
||||
</beans>
|
||||
|
Reference in New Issue
Block a user