|
@@ -0,0 +1,77 @@
|
|
|
+<?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:context="http://www.springframework.org/schema/context"
|
|
|
+ xmlns:mvc="http://www.springframework.org/schema/mvc"
|
|
|
+ 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
|
|
|
+ http://www.springframework.org/schema/mvc
|
|
|
+ http://www.springframework.org/schema/mvc/spring-mvc.xsd
|
|
|
+">
|
|
|
+<!--json整合 需要导入 jackson-annotations-*.jar,jackson-core-.jar,jackson-databind-.jar -->
|
|
|
+ <bean class="org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping" />
|
|
|
+ <bean class="org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter">
|
|
|
+ <property name="messageConverters">
|
|
|
+ <list>
|
|
|
+ <bean class="org.springframework.http.converter.StringHttpMessageConverter">
|
|
|
+ <property name="supportedMediaTypes">
|
|
|
+ <list>
|
|
|
+ <value>text/html; charset=UTF-8</value>
|
|
|
+ <value>application/json;charset=UTF-8</value>
|
|
|
+ </list>
|
|
|
+ </property>
|
|
|
+ </bean>
|
|
|
+ <bean class="org.springframework.http.converter.json.MappingJackson2HttpMessageConverter">
|
|
|
+ <property name="supportedMediaTypes">
|
|
|
+ <list>
|
|
|
+ <value>text/html; charset=UTF-8</value>
|
|
|
+ <value>application/json;charset=UTF-8</value>
|
|
|
+ </list>
|
|
|
+ </property>
|
|
|
+ </bean>
|
|
|
+ </list>
|
|
|
+ </property>
|
|
|
+ </bean>
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+<!-- 扫描包下所有类,为添加了@Service、@Component、@Controller、@Repository修饰的类创建对象并存入IOC容器-->
|
|
|
+ <context:component-scan base-package="gydx.springmybatis.controller"></context:component-scan>
|
|
|
+ <mvc:default-servlet-handler></mvc:default-servlet-handler>
|
|
|
+ <mvc:annotation-driven></mvc:annotation-driven>
|
|
|
+
|
|
|
+ <context:component-scan base-package="gydx.springmybatis.service"></context:component-scan>
|
|
|
+
|
|
|
+ <bean id="gydxdb" class="org.apache.commons.dbcp2.BasicDataSource">
|
|
|
+ <property name="driverClassName" value="com.mysql.cj.jdbc.Driver"></property>
|
|
|
+ <property name="url" value="jdbc:mysql://47.92.102.27:53306/gydx"></property>
|
|
|
+ <property name="username" value="gydx"></property>
|
|
|
+ <property name="password" value="gydx123456"></property>
|
|
|
+ </bean>
|
|
|
+
|
|
|
+ <bean id="sqlSessionFactory" class="org.mybatis.spring.SqlSessionFactoryBean">
|
|
|
+ <property name="dataSource" ref="gydxdb"></property>
|
|
|
+ <property name="mapperLocations" value="classpath:gydx/springmybatis/mapper/student.xml"></property>
|
|
|
+
|
|
|
+<!-- 显示SQL-->
|
|
|
+ <property name="configuration">
|
|
|
+ <bean class="org.apache.ibatis.session.Configuration">
|
|
|
+ <property name="logImpl" value="org.apache.ibatis.logging.stdout.StdOutImpl" />
|
|
|
+ </bean>
|
|
|
+ </property>
|
|
|
+ </bean>
|
|
|
+
|
|
|
+ <bean class="org.mybatis.spring.mapper.MapperScannerConfigurer">
|
|
|
+ <property name="sqlSessionFactoryBeanName" value="sqlSessionFactory"></property>
|
|
|
+ <property name="basePackage" value="gydx.springmybatis.mapper"></property>
|
|
|
+ </bean>
|
|
|
+
|
|
|
+ <bean id="transactionManger" class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
|
|
|
+ <property name="dataSource" ref="gydxdb"></property>
|
|
|
+ </bean>
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+</beans>
|