前言——項目整體的一些配置文件以及說明

這篇文章主要介紹項目的整體一些設置,避免在以後的開發過程中一點一點的配置

項目的地址

https://github.com/Pink-Smile/DatabaseDesign

使用的技術棧

  • SpringBoot 2.2.6
  • 前端UI:layui-2.x + X-admin2.2
  • 前後端數據傳輸:ajax + thymeleaf
  • Java版本:jdk1.8.0_251
  • Maven版本:apache-maven-3.6.2
  • Mybatis版本:Mybatis-2.0.0
  • 權限控制:Shiro

下面是項目使用的配置,整個項目所有的設置就是這樣

pom.xml項目依賴

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>2.2.5.RELEASE</version>
        <relativePath/> <!-- lookup parent from repository -->
    </parent>
    <groupId>pinksmile.database</groupId>
    <artifactId>demo</artifactId>
    <version>0.0.1-SNAPSHOT</version>
    <name>DatabaseManager</name>
    <description>Demo project for Spring Boot</description>

    <properties>
        <java.version>1.8</java.version>
    </properties>

    <dependencies>
        <!--分頁管理器-->
        <dependency>
            <groupId>com.github.pagehelper</groupId>
            <artifactId>pagehelper-spring-boot-starter</artifactId>
            <version>1.2.5</version>
        </dependency>
        <!--shiro-->
        <dependency>
            <groupId>org.apache.shiro</groupId>
            <artifactId>shiro-spring</artifactId>
            <version>1.4.2</version>
        </dependency>
        <!--thymeleaf-extras-shiro依賴-->
        <dependency>
            <groupId>com.github.theborakompanioni</groupId>
            <artifactId>thymeleaf-extras-shiro</artifactId>
            <version>2.0.0</version>
        </dependency>
        <!--shiro緩存-->
<!--        <dependency>-->
<!--            <groupId>org.apache.shiro</groupId>-->
<!--            <artifactId>shiro-ehcache</artifactId>-->
<!--            <version>1.4.0</version>-->
<!--        </dependency>-->
        <!-- aop依賴 -->
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-aop</artifactId>
        </dependency>
        <!--谷歌驗證碼-->
        <dependency>
            <groupId>com.github.penggle</groupId>
            <artifactId>kaptcha</artifactId>
            <version>2.3.2</version>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-data-jdbc</artifactId>
        </dependency>
        <!--thymeleaf模板-->
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-thymeleaf</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>
        </dependency>
        <dependency>
            <groupId>org.mybatis.spring.boot</groupId>
            <artifactId>mybatis-spring-boot-starter</artifactId>
            <version>2.0.0</version>
        </dependency>

        <dependency>
            <groupId>org.projectlombok</groupId>
            <artifactId>lombok</artifactId>
            <scope>provided</scope>
        </dependency>

        <dependency>
            <groupId>mysql</groupId>
            <artifactId>mysql-connector-java</artifactId>
            <scope>runtime</scope>
        </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>
    </dependencies>

    <build>
        <plugins>
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
            </plugin>
        </plugins>
    </build>

</project>

application.properties設置

spring.datasource.url=jdbc:mysql://localhost:3306/database-manager?serverTimezone=GMT%2B8&useSSL=false&characterEncoding=utf8
spring.datasource.username=root
spring.datasource.password=123456

server.port=8888

mybatis.mapper-locations=classpath:mapper/*.xml
mybatis.type-aliases-package=pinksmile.database.domin
mybatis.configuration.map-underscore-to-camel-case=true
mybatis.configuration.logImpl=org.apache.ibatis.logging.stdout.StdOutImpl

# 關閉模板緩存
spring.thymeleaf.cache=false
# 表示html頁面在resources文件夾下的templates文件夾中
spring.thymeleaf.prefix=classpath:/templates/
# 表示頁面後綴是html格式
spring.thymeleaf.suffix=.html
# 採用utf-8編碼,避免頁面亂碼
spring.thymeleaf.encoding=UTF-8
# 文檔MIME類型是text/html,也就是html格式的文檔
spring.thymeleaf.servlet.content-type=text/html

spring.mvc.date-format=yyyy-MM-dd
#spring.jackson.date-format=yyyy-MM-dd
#spring.jackson.time-zone=GMT+8

# 資源緩存時間,單位秒
spring.resources.cache.period=604800
# 開啓gzip壓縮
spring.resources.chain.compressed=true
# 啓用緩存
spring.resources.chain.cache=true
# 使用MD5版本號
spring.resources.chain.strategy.content.enabled=true
spring.resources.chain.strategy.content.paths=/**

數據庫創建文件請見Github

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章