One of the company's original projects is the Spring MVC framework. Now we need to go to Spring cloud, so we intend to convert to Spring boot project. Because we didn't know Spring boot very well before, we record the process of the project framework transformation and some pits encountered.
The original project is SSM and JSP, maven management package way. Project parent, public works common, front-end engineering platform, and custom front-end xxx.
Custom front-end xxx is platform-dependent and belongs to war engineering.
1. Create a springboot project quickly with idea
Select pom
Check Versions and Dependent web Starters
So you can simply create a parent project for spring boot.
2. We need to copy the jar s of the original mvc into the parent class.
All of spring jar s originally introduced in mvc can be directly replaced by the following (I exclude logging because log4j is used later)
<dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-web</artifactId> <exclusions> <exclusion> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-logging</artifactId> </exclusion> </exclusions> </dependency> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-test</artifactId> <scope>test</scope> </dependency> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-aop</artifactId> </dependency> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-context-support</artifactId> </dependency>
mybatis, connection pool, mysql database connection, and other related jar s are replaced by the following
Note: Introducing mybatis-plus can inherit BaseMapper with dao layer so as to save the mapper of CRUD operation of single table. I just introduce it here to use the yam-related configuration of mybatis-plus, which will be discussed later. Genee was excluded because I did not use Templates to cause an exception to the file to be missed when spring loads.
<dependency> <groupId>org.mybatis.spring.boot</groupId> <artifactId>mybatis-spring-boot-starter</artifactId> <version>${mybatis-spring-boot.version}</version> </dependency> <dependency> <groupId>mysql</groupId> <artifactId>mysql-connector-java</artifactId> <version>${mysql.version}</version> </dependency> <dependency> <groupId>com.alibaba</groupId> <artifactId>druid-spring-boot-starter</artifactId> <version>${druid.version}</version> </dependency> <dependency> <groupId>com.baomidou</groupId> <artifactId>mybatis-plus</artifactId> <version>${mybatisplus.version}</version> <exclusions> <exclusion> <groupId>com.baomidou</groupId> <artifactId>mybatis-plus-generate</artifactId> </exclusion> </exclusions> </dependency> <dependency> <groupId>com.baomidou</groupId> <artifactId>mybatisplus-spring-boot-starter</artifactId> <version>${mybatisplus.spring.boot.version}</version> </dependency>
The jar of log4j only needs to quote the following jar.
<dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-log4j</artifactId> <version>1.3.8.RELEASE</version> </dependency> <dependency> <groupId>org.apache.logging.log4j</groupId> <artifactId>log4j-core</artifactId> <version>2.11.1</version> </dependency>
Other related jar s depend on the company's personal need to configure them.
If the jar package has a conflict, you can eliminate the red line from the maven view in the idea, which is the conflict. If the conflict does not affect, you can ignore it.
Finally, configure a warehouse in Aliyun
<!-- Aliyun maven Warehouse --> <repositories> <repository> <id>public</id> <name>aliyun nexus</name> <url>http://maven.aliyun.com/nexus/content/groups/public/</url> <releases> <enabled>true</enabled> </releases> </repository> </repositories> <pluginRepositories> <pluginRepository> <id>public</id> <name>aliyun nexus</name> <url>http://maven.aliyun.com/nexus/content/groups/public/</url> <releases> <enabled>true</enabled> </releases> <snapshots> <enabled>false</enabled> </snapshots> </pluginRepository> </pluginRepositories>
At this point, the basic parent is built. Continue in the next section.