springboot简单项目_SpringBoot+MybatisPlus+Druid_mysql搭建简单的项目自动生成代码

c46a97dbf7e3ff2f3de2293f63b31365.png
97d438442eb7e769b33352e225e877c5.png
c960fa547306dbdf1fbd918f193af62a.png
bdd44a304cf1053e4ae6308d6385ec91.png
c2d4866a57716366baf9baa41256c32e.png
678757e34134b64eab1f4986b73054dc.png
1611afb6d78e821cd43680e4f47ea76c.png
0a4ff79b204b9ead12ae9187533ad563.png
f2dffef008eac0d37a3704145f51f622.png
019141e2259382720064a2bd661109b3.png

数据库

CREATE DATABASE test;

USE test;

CREATE TABLE `user` (

`id` BIGINT(20) NOT NULL AUTO_INCREMENT,

`username` VARCHAR(50) NOT NULL COMMENT '用户名',

`create_time` DATETIME DEFAULT NULL COMMENT '创建时间',

PRIMARY KEY (`id`),

UNIQUE KEY `username` (`username`)

) ENGINE=INNODB AUTO_INCREMENT=2 DEFAULT CHARSET=utf8 COMMENT='用户';

项目pom.xml

<?xml version="1.0" encoding="UTF-8"?>4.0.0com.dyp dyp-test 0.0.1-SNAPSHOTdyp-testDemo project for Spring BootjarUTF-8UTF-81.8org.springframework.boot spring-boot-starter-parent 2.0.0.BUILD-SNAPSHOTorg.springframework.boot spring-boot-starter-web com.baomidou mybatisplus-spring-boot-starter 1.0.4com.baomidou mybatis-plus 2.0.7org.apache.velocity velocity 1.7org.freemarker freemarker 2.3.28org.springframework.boot spring-boot-starter-jdbc mysql mysql-connector-java com.alibaba druid 1.1.9org.projectlombok lombok 0.10.1providedorg.springframework.boot spring-boot-maven-plugin spring-snapshotshttp://repo.spring.io/snapshottruespring-milestoneshttp://repo.spring.io/milestonespring-snapshotshttp://repo.spring.io/snapshotspring-milestoneshttp://repo.spring.io/milestone

application.yml 相关的配置

spring: datasource: type: com.alibaba.druid.pool.DruidDataSource driver-class-name: com.mysql.jdbc.Driver url: jdbc:mysql://localhost:3306/test?useUnicode=true&characterEncoding=utf8&allowMultiQueries=true username: root password: root druid: initial-size: 5 min-idle: 5 maxActive: 20 maxWait: 60000 timeBetweenEvictionRunsMillis: 60000 minEvictableIdleTimeMillis: 300000 validationQuery: SELECT 1 FROM DUAL testWhileIdle: true testOnBorrow: false testOnReturn: false poolPreparedStatements: true maxPoolPreparedStatementPerConnectionSize: 20 filters: stat,wall connectionProperties: druid.stat.mergeSql=true;druid.stat.slowSqlMillis=5000 web-stat-filter: enabled: true url-pattern: "/*" exclusions: "*.js,*.gif,*.jpg,*.bmp,*.png,*.css,*.ico,/druid/*" # DruidStatViewServlet stat-view-servlet: url-pattern: "/druid/*" allow: 127.0.0.1,192.168.1.1 deny: 192.168.1.1 reset-enable: false login-username: admin login-password: 123456mybatis-plus: mapper-locations: classpath:/com/dyp/dyptest/mapper/*/*.xml typeAliasesPackage: com.dyp.dyptest.entity global-config: id-type: 2 field-strategy: 2 db-column-underline: true refresh-mapper: true configuration: map-underscore-to-camel-case: true cache-enabled: falseserver: port: 8082

com.dyp.dyptest.config相关配置

package com.dyp.dyptest.config;import com.alibaba.druid.pool.DruidDataSource;import org.springframework.boot.context.properties.ConfigurationProperties;import org.springframework.context.annotation.Bean;import org.springframework.context.annotation.Configuration;import org.springframework.jdbc.datasource.DataSourceTransactionManager;import javax.sql.DataSource;/** * 数据源配置 */@Configurationpublic class DataSourcesConfig { @Bean(name="dataSource") @ConfigurationProperties(prefix="spring.datasource") public DataSource dataSource(){ return new DruidDataSource(); } // 配置事物管理器 @Bean(name="transactionManager") public DataSourceTransactionManager transactionManager(){ return new DataSourceTransactionManager(dataSource()); }}
package com.dyp.dyptest.config;import com.alibaba.druid.support.http.StatViewServlet;import com.alibaba.druid.support.http.WebStatFilter;import org.springframework.boot.web.servlet.FilterRegistrationBean;import org.springframework.boot.web.servlet.ServletRegistrationBean;import org.springframework.context.annotation.Bean;import org.springframework.context.annotation.Configuration;@Configurationpublic class DruidConfiguration { @Bean public ServletRegistrationBean startViewServlet(){ ServletRegistrationBean servletRegistrationBean = new ServletRegistrationBean(new StatViewServlet(),"/druid/*"); // IP白名单 servletRegistrationBean.addInitParameter("allow
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值