最近做了一个以SpringBoot+Mybaits为框架前后端分离的商城秒杀项目,主要使用的工具是Idea和Maven,SpringBoot是一个功能十分强大的框架集合,里面包含了很多的框架.
工程的开始,我先配置好了应该有的文件结构
然后在Pom.xml里配置好要用的Jar包必要的SpringBoot有关的两个Jar包,`
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.1.4.RELEASE</version>
</parent>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
然后再配置必要的数据库连接有关的Jar包
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>5.1.40</version>
</dependency>
还有必要的数据库连接池这里我们用的是阿里里巴巴的德鲁伊的数据库连接池
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>druid</artifactId>
<version>1.1.3</version>
</dependency>
实现工程持久层我用的是Mybatis框架,所以我配置了springBoot和Mybaits的整合Jar包
<dependency>
<groupId>org.mybatis.spring.boot</groupId>
<artifactId>mybatis-spring-boot-starter</artifactId>
<version>1.3.1</version>
</dependency>
最重要的是在Pom.xml里配置一个插件用于逆向工程由数据库生成持久层代码.
<pluginManagement><!-- lock down plugins versions to avoid using Maven defaults (may be moved to parent pom) -->
<plugins>
<!-- clean lifecycle, see https://maven.apache.org/ref/current/maven-core/lifecycles.html#clean_Lifecycle -->
<plugin>
<artifactId>maven-clean-plugin</artifactId>
<version>3.1.0</version>
</plugin>
<!-- default lifecycle, jar packaging: see https://maven.apac