【SpringBoot】配置篇

   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>

    <!--   JDK8 对应的版本要在3.0.0以下     -->
    <parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>2.5.6</version>
        <relativePath/>
    </parent>

    <!--   复制项目后需要修改这里的名字     -->
    <groupId>com.example</groupId>
    <artifactId>springBootStudy</artifactId>
    <version>0.0.1-SNAPSHOT</version>
    <name>springBootStudy</name>
    <description>springBootStudy</description>


    <!--   java版本号     -->
    <properties>
        <java.version>8</java.version>
    </properties>



    <dependencies>
        <!--  thymeleaf控制返回HTML模板   -->
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-thymeleaf</artifactId>
        </dependency>

        <!--  springboot启动器   -->
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>
        </dependency>

        <!--  springboot热启动   -->
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-devtools</artifactId>
            <scope>runtime</scope>
            <optional>true</optional>
        </dependency>

        <!--  生产配置元数据 -->
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-configuration-processor</artifactId>
            <optional>true</optional>
        </dependency>

        <!--  简化JavaBean的编写-->
        <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>
        </dependency>


        <!--   数据库配置  我这里是sqlit3的配置-->
        <dependency>
            <groupId>com.alibaba</groupId>
            <artifactId>druid-spring-boot-starter</artifactId>
            <version>1.2.6</version>
        </dependency>
        <dependency>
            <groupId>org.xerial</groupId>
            <artifactId>sqlite-jdbc</artifactId>
            <version>3.36.0</version>
        </dependency>
        <dependency>
            <groupId>p6spy</groupId>
            <artifactId>p6spy</artifactId>
            <version>3.9.1</version>
        </dependency>
        <dependency>
            <groupId>com.baomidou</groupId>
            <artifactId>mybatis-plus-boot-starter</artifactId>
            <version>3.5.1</version>
        </dependency>
        <!--     数据库配置  -->
    </dependencies>


    <build>
        <plugins>
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
                <configuration>
                    <excludes>
                        <exclude>
                            <groupId>org.projectlombok</groupId>
                            <artifactId>lombok</artifactId>
                        </exclude>
                    </excludes>
                </configuration>
            </plugin>
        </plugins>
    </build>

</project>

   application.yml

server:
  port: 8080


spring:
  datasource:
    # druid配置
    druid:
      # url: jdbc:p6spy:sqlite:C:\Users\Administrator\Desktop\springBootStudy\java.db
      url: jdbc:p6spy:sqlite:C:\Users\Administrator\Desktop\BaiduSyncdisk\springBootStudy\java.db
      driver-class-name: com.p6spy.engine.spy.P6SpyDriver
      username:
      password:


mybatis-plus:
  global-config:
    db-config:
      # 配置ID自增
      id-type: auto
  configuration:
    # 配置日志
    log-impl: org.apache.ibatis.logging.stdout.StdOutImpl

   分页配置 拦截器

# 我的目录:  java.config.MyBatisPlusConfig

@Configuration
public class MyBatisPlusConfig { // 分页配置 @Bean public MybatisPlusInterceptor mybatisPlusInterceptor() { // 定义MP拦截器 MybatisPlusInterceptor interceptor = new MybatisPlusInterceptor(); // 添加具体的拦截器 这里我使用的是sqlit3 interceptor.addInnerInterceptor(new PaginationInnerInterceptor(DbType.SQLITE)); return interceptor; } }

 

posted @ 2023-01-12 16:48  PythonNew_Mr.Wang  Views(50)  Comments(0)    收藏  举报