网站开发报价单模板,深圳网站建设推广平台,基本seo,软件开发业务流程图SSM一般是分开学的#xff0c;Spring#xff0c;SpringMVC#xff0c;Mybatis。学完之后整合也是需要学习一段时间。下面是一次整合的实践...SSM的整合顺序一般先整合Spring和Mybatis。再整合SpringMVC。Spring整合Mybatis首先把文件放到lib的文件夹下。然后在src目录下新建…SSM一般是分开学的SpringSpringMVCMybatis。学完之后整合也是需要学习一段时间。下面是一次整合的实践...SSM的整合顺序一般先整合Spring和Mybatis。再整合SpringMVC。Spring整合Mybatis首先把文件放到lib的文件夹下。然后在src目录下新建Spring的配置文件(applicationContext.xml)。然后开启自动扫描。然后applicationContext.xml整合mybatis的全局配置文件。这个Bean的名字是固定的。org.springframework.beans.factory.config.PropertyPlaceholderConfigurer通过这个bean可以通过db.properties文件中的key使用value。创建一个数据源的对象类名固定org.apache.commons.dbcp.BasicDataSource。这里可以直接使用db.properties中的key。配置SqlSessionFactory的bean注入映射器有两种方法。较第二种简单一些扫描dao包下所有的配置。一个个的单独配置配置到这里已经能在dao包中使用Mapper.xml配置文件也可以在Dao上使用注解2者取其一。这里不需要在dao上注解Repository。在Service层上需要需要注解Service具体视情况而定。在Service中注入Dao用Resource通过名字注入。整合SpringMVC加入SpringMVC的配置文件到src目录下。一个小例子。编写自己的Controller和视图(JSPThymeleaf等)。修改web.xml加载springspringmvc配置文件contextConfigLocationclasspath:applicationContext.xmlorg.springframework.web.context.ContextLoaderListenerspringDispatcherServletorg.springframework.web.servlet.DispatcherServletcontextConfigLocationclasspath:springmvc-servlet.xml1springDispatcherServlet*.action