码迷,mamicode.com
首页 > 编程语言 > 详细

SpringBoot实战(一)--构建项目基本框架

时间:2020-04-10 22:29:00      阅读:111      评论:0      收藏:0      [点我收藏+]

标签:option   directory   html   nal   set   xadmin   control   serve   img   

基于 https://www.bilibili.com/video/BV1pJ411u7ZH 视频基础实现

后端:SpringBoot + MySQL8.0.15 +Mybatis+Druid

前端:基于layui的轻量级前端后台管理框架

接口文档:Swagger

模板引擎:thymeleaf


技术图片
  1 <?xml version="1.0" encoding="UTF-8"?>
  2 <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  3          xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
  4     <modelVersion>4.0.0</modelVersion>
  5     <parent>
  6         <groupId>org.springframework.boot</groupId>
  7         <artifactId>spring-boot-starter-parent</artifactId>
  8         <version>2.2.5.RELEASE</version>
  9         <relativePath/> <!-- lookup parent from repository -->
 10     </parent>
 11     <groupId>com.beilin</groupId>
 12     <artifactId>demo</artifactId>
 13     <version>0.0.1-SNAPSHOT</version>
 14     <name>demo</name>
 15     <description>Demo project for Spring Boot</description>
 16 
 17     <properties>
 18         <java.version>1.8</java.version>
 19     </properties>
 20 
 21     <dependencies>
 22         <dependency>
 23             <groupId>org.springframework.boot</groupId>
 24             <artifactId>spring-boot-starter-web</artifactId>
 25         </dependency>
 26         <!--mysql依赖-->
 27         <dependency>
 28             <groupId>mysql</groupId>
 29             <artifactId>mysql-connector-java</artifactId>
 30             <version>8.0.15</version>
 31         </dependency>
 32         <!--mybatis依赖-->
 33         <dependency>
 34             <groupId>org.mybatis.spring.boot</groupId>
 35             <artifactId>mybatis-spring-boot-starter</artifactId>
 36             <version>2.1.0</version>
 37         </dependency>
 38         <dependency>
 39             <groupId>com.github.pagehelper</groupId>
 40             <artifactId>pagehelper</artifactId>
 41             <version>5.1.8</version>
 42         </dependency>
 43 
 44         <!-- 阿里系的Druid依赖包 -->
 45         <dependency>
 46             <groupId>com.alibaba</groupId>
 47             <artifactId>druid-spring-boot-starter</artifactId>
 48             <version>1.1.10</version>
 49         </dependency>
 50         <!-- 引入thymeleaf模板引擎-->
 51         <dependency>
 52             <groupId>org.springframework.boot</groupId>
 53             <artifactId>spring-boot-starter-thymeleaf</artifactId>
 54         </dependency>
 55         <!--Sprinh Security-->
 56 <!--        <dependency>-->
 57 <!--            <groupId>org.springframework.boot</groupId>-->
 58 <!--            <artifactId>spring-boot-starter-security</artifactId>-->
 59 <!--        </dependency>-->
 60         <dependency>
 61             <groupId>io.springfox</groupId>
 62             <artifactId>springfox-swagger2</artifactId>
 63             <version>2.9.2</version>
 64         </dependency>
 65         <dependency>
 66              <groupId>io.springfox</groupId>
 67              <artifactId>springfox-swagger-ui</artifactId>
 68              <version>2.9.2</version>
 69         </dependency>
 70 <!--        &lt;!&ndash;redis&ndash;&gt;-->
 71 <!--        <dependency>-->
 72 <!--            <groupId>org.springframework.boot</groupId>-->
 73 <!--            <artifactId>spring-boot-starter-data-redis</artifactId>-->
 74 <!--        </dependency>-->
 75          <!--devtools热部署-->
 76         <dependency>
 77             <groupId>org.springframework.boot</groupId>
 78             <artifactId>spring-boot-devtools</artifactId>
 79             <optional>true</optional>
 80         </dependency>
 81         <dependency>
 82             <groupId>org.springframework.boot</groupId>
 83             <artifactId>spring-boot-starter-test</artifactId>
 84             <scope>test</scope>
 85 
 86         </dependency>
 87         <dependency>
 88             <groupId>commons-collections</groupId>
 89             <artifactId>commons-collections</artifactId>
 90             <version>3.2.2</version>
 91         </dependency>
 92         <dependency>
 93             <groupId>org.projectlombok</groupId>
 94             <artifactId>lombok</artifactId>
 95             <optional>true</optional>
 96         </dependency>
 97         <dependency>
 98             <groupId>com.alibaba</groupId>
 99             <artifactId>fastjson</artifactId>
100             <version>1.2.60</version>
101         </dependency>
102     </dependencies>
103 
104     <build>
105         <plugins>
106             <plugin>
107                 <groupId>org.springframework.boot</groupId>
108                 <artifactId>spring-boot-maven-plugin</artifactId>
109             </plugin>
110         </plugins>
111         <resources>
112             <resource>
113                 <directory>src/main/java</directory>
114                 <includes>
115                     <include>**/*.xml</include>
116                 </includes>
117                 <filtering>true</filtering>
118             </resource>
119         </resources>
120     </build>
121 
122 </project>
pom.xml
技术图片
 1 #项目环境设置
 2 spring.profiles.active=dev
 3 #项目编码设置
 4 spring.http.encoding.force=true
 5 spring.http.encoding.charset=UTF-8
 6 spring.http.encoding.enabled=true
 7 server.tomcat.uri-encoding=UTF-8
 8 
 9 api-url=/api
10 
11 #配置mybatis
12 #配置xml映射路径
13 mybatis.mapper-locations=classpath:com.beilin/mapper/**.xml
14 #配置实体类别名
15 mybatis.type-aliases-package=com.beilin.entity
16 #开启驼峰命名法
17 mybatis.configuration.map-underscore-to-camel-case=true
18 
19 #配置Mysql连接
20 spring.datasource.druid.url=jdbc:mysql://localhost:3306/demo?useUnicode=true&useSSL=false&characterEncoding=utf8&serverTimezone=UTC
21 spring.datasource.druid.username=root
22 spring.datasource.druid.password=root
23 spring.datasource.druid.driver-class-name=com.mysql.cj.jdbc.Driver
application.properties

导入xadmin(百度搜xadmin)

链接:https://pan.baidu.com/s/1OIRqR9IpAH_7zBa8sf4riA
提取码:g09o
(包含个人尝试修改)

技术图片

 

 thymeleaf模板 默认路径resources

静态资源--static 目录

技术图片

 

 

 页面--templates

技术图片

 

 

 抽取公共资源--templates目录新建header.html

技术图片

 页面引用

技术图片

 

 

 测试

 1 @Controller
 2 public class LoginController {
 3 
 4     @GetMapping("/index")
 5     public ModelAndView index(ModelAndView model) {
 6         model.setViewName("index");
 7         return model;
 8     }
 9 
10 }

技术图片

 

SpringBoot实战(一)--构建项目基本框架

标签:option   directory   html   nal   set   xadmin   control   serve   img   

原文地址:https://www.cnblogs.com/wx60079/p/12676509.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!