ssm framework integration

#Find my framework integration for a long time, and finally got it done today. make a small dome#

1. Build a web project

 

2. Import the required jar package into it

 

 3. springmvc configuration

  <context:component-scan base-package="com.zspt.lab.web"></context:component-scan>
  <mvc:annotation-driven />

  <bean
  class="org.springframework.web.servlet.view.InternalResourceViewResolver">
    <property name="prefix" value="/WEB-INF/view/"></property>
    <property name="suffix" value=".jsp"></property>
  </bean>

4. db.properties configuration

  jdbc.driver=com.mysql.jdbc.Driver
  jdbc.url=jdbc:mysql://localhost:3306/admin_zspt
  jdbc.username= #Username to connect to the database
  jdbc.password= #Password to connect to the database

 

5. applicationContext-dao.xml configuration

  

<!-- Load configuration file-->
<context:property-placeholder location="classpath:*.properties" />

<!-- 数据库连接池 -->
<bean id="dataSource" class="com.alibaba.druid.pool.DruidDataSource"
destroy-method="close">
<property name="url" value="${jdbc.url}" />
<property name="username" value="${jdbc.username}" />
<property name="password" value="${jdbc.password}" />
<property name="driverClassName" value="${jdbc.driver}" />
<property name="maxActive" value="10" />
<property name="minIdle" value="5" />
</bean>

<!-- Let spring manage sqlsessionfactory using mybatis and spring integration package-->
<bean id="sqlSessionFactory" class="org.mybatis.spring.SqlSessionFactoryBean">
<!-- database connection pool-->
<property name= "dataSource" ref="dataSource" />
<!-- Load mybatis global configuration file-->
<property name="configLocation" value="classpath:mybatis/sqlMapConfig.xml" />
</bean>

<!-- mapple扫描 -->
<bean class="org.mybatis.spring.mapper.MapperScannerConfigurer">
<property name="basePackage" value="com.zspt.lab.dao" />
</bean>

 

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324815458&siteId=291194637