1、导包
<dependencies> <dependency> <groupId>org.springframework.bootgroupId> <artifactId>spring-boot-starter-webartifactId> dependency> <dependency> <groupId>com.baomidougroupId> <artifactId>mybatis-plus-boot-starterartifactId> <version>3.5.1version> dependency> <dependency> <groupId>org.mybatis.spring.bootgroupId> <artifactId>mybatis-spring-boot-starterartifactId> <version>2.2.2version> dependency> <dependency> <groupId>com.alibabagroupId> <artifactId>druid-spring-boot-starterartifactId> <version>1.2.16version> dependency> <dependency> <groupId>com.alibabagroupId> <artifactId>druid-spring-boot-starterartifactId> <version>1.2.11version> dependency> <dependency> <groupId>org.springframework.bootgroupId> <artifactId>spring-boot-starter-jdbcartifactId> dependency> <dependency> <groupId>mysqlgroupId> <artifactId>mysql-connector-javaartifactId> <scope>runtimescope> dependency> <dependency> <groupId>com.baomidougroupId> <artifactId>mybatis-plus-generatorartifactId> <version>3.5.2version> dependency> <dependency> <groupId>org.springframework.bootgroupId> <artifactId>spring-boot-starter-freemarkerartifactId> dependency> <dependency> <groupId>org.projectlombokgroupId> <artifactId>lombokartifactId> <optional>trueoptional> dependency> <dependency> <groupId>org.springframework.bootgroupId> <artifactId>spring-boot-starter-testartifactId> <scope>testscope> dependency> dependencies> <build> <resources> <resource> <directory>src/main/javadirectory> <includes> <include>***.xmlinclude> includes> <filtering>falsefiltering> resource> <resource> <directory>src/main/resourcesdirectory> <includes> <include>***.xmlinclude> includes> <filtering>falsefiltering> resource> resources> <plugins> <plugin> <groupId>org.springframework.bootgroupId> <artifactId>spring-boot-maven-pluginartifactId> <configuration> <excludes> <exclude><groupId>org.projectlombokgroupId><artifactId>lombokartifactId> exclude> excludes> configuration> plugin> plugins> <plugins> <plugin> <groupId>org.springframework.bootgroupId> <artifactId>spring-boot-maven-pluginartifactId> <executions> <execution> <goals><goal>repackagegoal> goals> execution> executions> plugin> plugins> <finalName>项目名finalName> build>
2、全部的配置文件(配置JDBC、Druid、MP)
spring: datasource: driver-class-name: com.mysql.cj.jdbc.Driver username: root password: 123456 url: jdbc:mysql://localhost:3306/test?useUnicode=true&characterEncoding=utf-8&serverTimezone=Asia/Shanghai&useSSL=true&allowMultiQueries=true # Oracle配置 #url: jdbc:oracle:thin:@127.0.0.1:1521:test #username: root #password: 123456 #driver-class-name: oracle.jdbc.driver.OracleDriver # 配置druid数据源 type: com.alibaba.druid.pool.DruidDataSource # druid 配置 druid: # 打开我们的内置监控页面,打开后我们才可以有相应的web界面 stat-view-servlet: enabled: true url-pattern: /druid*.propertiesinclude> <include>***.propertiesinclude> <include>**/*.xmlinclude> includes> <filtering>falsefiltering> resource> resources>build>
来源地址:https://blog.csdn.net/qq_57581439/article/details/130767476