The detailed process of transferring SSM project to Spring Boot project (including precautions for transferring eclipse to idea)

The detailed process of transferring SSM project to Spring Boot project (including eclipse–>idea precautions)



1. Create a Spring Boot project and import dependencies. Refer to the relevant blog post above

Second, static page transfer

enter description here

Three, background code

enter description here

Fourth, separate the mapper file

enter description here

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

enter description here

Six, mysql and mybatis configuration

  1. mysql
    enter description here
  2. Change the location of the mapper.xml file of mybatis and configure the package path.
    enter description here
  3. Mybatis alias setting (directly set the pojo package, then you can omit the package name and use the class name directly in mapper.xml)
    enter description here

Seven, the configuration of interceptors and filters (mainly changed its registration method, from the configuration method to java class configuration)

  1. Interceptor
    enter description here

  2. filter
    enter description here

  3. 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)

enter description here

Nine, the project default jump home page settings (new Controller)

enter description here

/* **********************************直接访问首页************************************* */
@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

  1. The mapper auto-injection error can be ignored, or @Component can be added to the mapper interface.
  2. The image verification code may be invalid, please refer to the second method in the blog post: Use image verification code in Java
  3. PageHelper paging needs to replace the spring boot type pom dependency

Guess you like

Origin blog.csdn.net/qq_39231769/article/details/103099499