IDEA创建SpringBoot项目,前后端分离
- 1、创建项目
- 2、点击next,进入选择springboot组件阶段
- 4、点击finish即可完成创建springboot项目
- 5、启动项目:创建成功后进入启动类,启动application类有如下输出即代表创建成功![,](https://img-blog.csdnimg.cn/20200716220241414.png?x-oss-process=image/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L3FxXzQzMjE5OTAy,size_16,color_FFFFFF,t_70)
- 6、下面是.yml配置文件中有关数据库和redis,shiro的一些配置
- 7、以下是pom.xml中需要添加的依赖,springmvc,mysql等等
- 8、接着开始用官网下载的map代码生成器生成mapper层,model层,service层,controller层的代码,运行main方法后直接输入数据库中的表名回车即可生成
- 10、接下来就可以在controller层编写接口了
1、创建项目
2、点击next,进入选择springboot组件阶段
选择如图的springboot组件 Developer Tools->Spring Boot DevTools
->LomBook
Web–>Spring Web
SQL–>MySQL Driver 数据库驱动
4、点击finish即可完成创建springboot项目
5、启动项目:创建成功后进入启动类,启动application类有如下输出即代表创建成功![,](https://img-blog.csdnimg.cn/20200716220241414.png?x-oss-process=image/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L3FxXzQzMjE5OTAy,size_16,color_FFFFFF,t_70)
6、下面是.yml配置文件中有关数据库和redis,shiro的一些配置
# DataSource Config
spring:
datasource:
driver-class-name: com.mysql.jdbc.Driver # mysql8.0+
url: jdbc:mysql://localhost:3306/pxforestpolice?useUnicode=true&useSSL=false&characterEncoding=utf8&serverTimezone=Asia/Shanghai
username: root
password: 123456
servlet:
multipart:
max-file-size: 5MB
max-request-size: 30MB
mvc:
static-path-pattern: /**
resources:
static-locations: file:E:\MyAllProject\IDEAPro4\PxForestpPlice
mybatis-plus:
mapper-locations: classpath*:/mapper/**Mapper.xml
server:
port: 8081
shiro-reids:
enabled: true
redis-manager:
host: 127.0.0.1:6379
markerhub:
jwt:
# 加密秘钥
secret: f4e2e52034348f86b67cde581c0f9eb5
# token有效时长,7天,单位秒
expire: 604800
header: Authorization
# java.io.FileNotFoundException: class path resource [templates/]
# cannot be resolved to absolute file path because it does not reside in the file system:
# jar:file:/tmp/vueblog-0.0.1-SNAPSHOT.jar!/BOOT-INF/lib/mybatis-plus-generator-3.2.0.jar!/templates/
# debug: true
# 对于spring-boot starter maven依赖为2.0以下时使用:
# 在application.properties/yml中配置以下属性
#单文件上传最大大小,默认1Mb
# spring.http.multipart.maxFileSize=5Mb
#多文件上传时最大大小,默认10Mb
# spring.http.multipart.maxRequestSize=30Mb
# spring-boot starter maven依赖为2.0及以上时,属性变更为:
#spring.servlet.multipart.max-file-size=5Mb
#spring.servlet.multipart.max-request-size=30Mb
7、以下是pom.xml中需要添加的依赖,springmvc,mysql等等
`<?xml version="1.0" encoding="UTF-8"?>
4.0.0
org.springframework.boot
spring-boot-starter-parent
2.2.6.RELEASE
com.dxk.pxforestpolice
pxforestpolice
0.0.1-SNAPSHOT
pxforestpolice
jar
Demo project for Spring Boot
<properties>
<java.version>1.8</java.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-devtools</artifactId>
<scope>runtime</scope>
<optional>true</optional>
</dependency>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<optional>true</optional>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
<exclusions>
<exclusion>
<groupId>org.junit.vintage</groupId>
<artifactId>junit-vintage-engine</artifactId>
</exclusion>
</exclusions>
</dependency>
<!--locadate/locadatetime的时间依赖-->
<dependency>
<groupId>org.mybatis</groupId>
<artifactId>mybatis-typehandlers-jsr310</artifactId>
<version>1.0.2</version>
</dependency>
<!--mp-->
<dependency>
<groupId>com.baomidou</groupId>
<artifactId>mybatis-plus-boot-starter</artifactId>
<version>3.2.0</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-freemarker</artifactId>
</dependency>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>5.1.8</version>
<scope>runtime</scope>
</dependency>
<!--mp代码生成器-->
<dependency>
<groupId>com.baomidou</groupId>
<artifactId>mybatis-plus-generator</artifactId>
<version>3.2.0</version>
</dependency>
<!-- hutool -->
<dependency>
<groupId>cn.hutool</groupId>
<artifactId>hutool-all</artifactId>
<version>5.3.3</version>
</dependency>
<!-- jwt -->
<dependency>
<groupId>io.jsonwebtoken</groupId>
<artifactId>jjwt</artifactId>
<version>0.9.1</version>
</dependency>
<!-- shiro-redis -->
<dependency>
<groupId>org.crazycake</groupId>
<artifactId>shiro-redis-spring-boot-starter</artifactId>
<version>3.2.1</version>
</dependency>
<!--gson-->
<dependency>
<groupId>at.stefangeyer.challonge.serializer</groupId>
<artifactId>gson</artifactId>
<version>2.1.0</version>
<type>pom</type>
</dependency>
<!--文件上传-->
<dependency>
<groupId>commons-fileupload</groupId>
<artifactId>commons-fileupload</artifactId>
<version>1.3.3</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>3.0.2</version>
<configuration>
<archive>
<manifest>
<addClasspath>true</addClasspath>
<mainClass>com.dxk.pxforestpolice.PxforestpoliceApplication</mainClass> <!-- 此处为主入口-->
</manifest>
</archive>
</configuration>
</plugin>
</plugins>
</build>
`