当前位置:网站首页>Steps of building SSM framework

Steps of building SSM framework

2022-07-07 12:49:00 Six years of Surabaya

SSM Steps of framework construction
1. Import Spring、SpringMVC、MyBatis Dependence
2. Import Spring、SpringMVC、MyBatis Configuration file for
3. stay Spring The following contents are configured in the configuration file of :
(1) Configure data sources

(2) To configure MyBatis The factory of conversation SqlSessionFactoryBean, And inject the data source

(3) To configure MyBatis Automatic scanning DAO layer Mapper Interface and configuration MyBatis Path to map file

(4) adopt component-scan Comment on service Scanning of layers

(5) Configure the propagation characteristics of transactions 、 Isolation level 、 Rollback strategy , Let those add、delete、update The first method starts the commit and rollback of transactions , Other methods are read-only transactions .

(6) Configure the transaction management aspect class , Crosscut service layer .

4. stay SpringMVC The following is configured in the configuration file :

(1) Use component-scan Tag open right controller Scanning of layers

(2) adopt annotation-driven Tags enable annotation driven

(3) Configure the view parser

(4) If you need to upload files , You also need to configure the file upload parser , And specify the size of file upload Limit

5. stay MyBatis The following contents are configured in the configuration file of :

(1) Configure printing on the console SQL sentence

(2) Configure enable L2 cache

(3) Configure underline to turn to small hump automatically

6. stay web.xml The following is configured in

(1) To configure Spring Listening in , And load Spring Configuration file for

(2) To configure SpringMVC Core controller of DispatcherServlet And load SpringMVC Configuration file for

(3) In order to prevent Chinese garbled , Generally, you will also configure an encoding filter and set the character encoding set to UTF-8

7. Actually, that's all , our SSM Even if the framework is built , Then you can develop the project .

Create a new control layer and add @Controller annotation , Then add @RequestMapping annotation , Next, in the control layer class, pass @Autowired or @Resource Annotation injection Service layer , stay Service Layers pass through @Autowired or @Resource Annotation injection DAO layer , What needs to be noted here is ,DAO Layer has only interfaces but no implementation classes , It's through MyBatis In the mapping file namespace Indicate the implemented DAO layer Mapper Interface , And pass MyBatis In the mapping file SQL Of ID Indicates the call DAO layer Mapper Interface method to be executed SQL sentence .

原网站

版权声明
本文为[Six years of Surabaya]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/188/202207071037184178.html