The detailed process of transferring SSM project to Spring Boot project (including eclipse–>idea precautions)
Article Directory
- SSM project to Spring Boot project detailed process (including eclipse-->idea precautions)
-
- 1. Create a Spring Boot project and import dependencies. Refer to the relevant blog post above
- Second, static page transfer
- Three, background code
- Fourth, separate the mapper file
- Fifth, the operating mode change (due to the built-in tomcat, you can run the project directly by running the main method) and the configuration of annotation scanning
- Six, mysql and mybatis configuration
- Seven, the configuration of interceptors and filters (mainly changed its registration method, from the configuration method to java class configuration)
- 8. Transaction configuration (directly use @Transactional annotation on the required class or method in ServiceImpl)
- Nine, the project default jump home page settings (new Controller)
- 10. Other
- This article mainly records the precautions in transferring the SSM project to the Spring Boot project. Including the transfer of main configuration files in SSM
Related blog posts: - Spring Boot common pom dependencies: Summary of Spring Boot common dependencies
- Idea to create a Spring Boot project introduction: idea to create a new Spring Boot project + a brief introduction to the project directory + project package operation
1. Create a Spring Boot project and import dependencies. Refer to the relevant blog post above
Second, static page transfer
Three, background code
Fourth, separate the mapper file
Fifth, the operating mode change (due to the built-in tomcat, you can run the project directly by running the main method) and the configuration of annotation scanning
Six, mysql and mybatis configuration
- mysql
- Change the location of the mapper.xml file of mybatis and configure the package path.
- Mybatis alias setting (directly set the pojo package, then you can omit the package name and use the class name directly in mapper.xml)
Seven, the configuration of interceptors and filters (mainly changed its registration method, from the configuration method to java class configuration)
-
Interceptor
-
filter
-
With interceptor, filter, registration code:
Spring Boot project filter, interceptor, and its registration
8. Transaction configuration (directly use @Transactional annotation on the required class or method in ServiceImpl)
Nine, the project default jump home page settings (new Controller)
/* **********************************直接访问首页************************************* */
@Configuration
public class WebConfigurer implements WebMvcConfigurer {
@Override
public void addViewControllers(ViewControllerRegistry registry) {
registry.addViewController("/").setViewName("forward:/login.html");
registry.setOrder(Ordered.HIGHEST_PRECEDENCE);
}
}
10. Other
- The mapper auto-injection error can be ignored, or @Component can be added to the mapper interface.
- The image verification code may be invalid, please refer to the second method in the blog post: Use image verification code in Java
- PageHelper paging needs to replace the spring boot type pom dependency