日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 运维知识 > 数据库 >内容正文

数据库

mysql逆向工程_Mybatis+Mysql逆向工程

發(fā)布時間:2025/3/20 数据库 41 豆豆
生活随笔 收集整理的這篇文章主要介紹了 mysql逆向工程_Mybatis+Mysql逆向工程 小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.

目錄結構:

pom文件:

4.0.0

org.springframework.boot

spring-boot-starter-parent

1.5.18.RELEASE

com.atyss

springboot-mybatis

0.0.1-SNAPSHOT

springboot-mybatis

Demo project for Spring Boot

1.8

org.springframework.boot

spring-boot-starter-jdbc

org.springframework.boot

spring-boot-starter-web

org.mybatis.spring.boot

mybatis-spring-boot-starter

1.3.2

mysql

mysql-connector-java

runtime

com.alibaba

druid

1.1.8

org.springframework.boot

spring-boot-starter-test

test

org.springframework.boot

spring-boot-maven-plugin

yml配置文件:

spring:

datasource:

# 數(shù)據(jù)源基本配置

username: root

password: 123456

driver-class-name: com.mysql.jdbc.Driver

url: jdbc:mysql://localhost:3306/mybatis

type: com.alibaba.druid.pool.DruidDataSource

# 數(shù)據(jù)源其他配置

initialSize: 5

minIdle: 5

maxActive: 20

maxWait: 60000

timeBetweenEvictionRunsMillis: 60000

minEvictableIdleTimeMillis: 300000

validationQuery: SELECT 1 FROM DUAL

testWhileIdle: true

testOnBorrow: false

testOnReturn: false

poolPreparedStatements: true

# 配置監(jiān)控統(tǒng)計攔截的filters,去掉后監(jiān)控界面sql無法統(tǒng)計,'wall'用于防火墻

filters: stat,wall,log4j

maxPoolPreparedStatementPerConnectionSize: 20

useGlobalDataSourceStat: true

connectionProperties: druid.stat.mergeSql=true;druid.stat.slowSqlMillis=500

mybatis:

# 指定全局配置文件位置

config-location: classpath:mybatis/mybatis-config.xml

# 指定sql映射文件位置

mapper-locations: classpath:mybatis/mapper/*.xml

druid配置文件:

package com.mybatisbgm.demo.config;

import com.alibaba.druid.pool.DruidDataSource;

import com.alibaba.druid.support.http.StatViewServlet;

import com.alibaba.druid.support.http.WebStatFilter;

import org.springframework.boot.context.properties.ConfigurationProperties;

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;

import javax.sql.DataSource;

import java.util.Arrays;

import java.util.HashMap;

import java.util.Map;

@Configuration

public class DruidConfig {

@ConfigurationProperties(prefix = "spring.datasource")

@Bean

public DataSource druid(){

return new DruidDataSource();

}

//配置Druid的監(jiān)控

//1、配置一個管理后臺的Servlet

@Bean

public ServletRegistrationBean statViewServlet(){

ServletRegistrationBean bean = new ServletRegistrationBean(new StatViewServlet(), "/druid/*");

Map initParams = new HashMap<>();

initParams.put("loginUsername","admin");

initParams.put("loginPassword","123456");

//initParams.put("allow","");//默認就是允許所有訪問

//initParams.put("deny","192.168.56.1");

bean.setInitParameters(initParams);

return bean;

}

//2、配置一個web監(jiān)控的filter

@Bean

public FilterRegistrationBean webStatFilter(){

FilterRegistrationBean bean = new FilterRegistrationBean();

bean.setFilter(new WebStatFilter());

Map initParams = new HashMap<>();

initParams.put("exclusions","*.js,*.css,/druid/*");

bean.setInitParameters(initParams);

bean.setUrlPatterns(Arrays.asList("/*"));

return bean;

}

}

最主要的bgm.xml

/p>

PUBLIC "-//mybatis.org//DTD MyBatis Generator Configuration 1.0//EN"

"http://mybatis.org/dtd/mybatis-generator-config_1_0.dtd">

test運行文件:

public static void main(String[] args) throwsException {

List warnings = new ArrayList();boolean overwrite = true;//1、獲取mbg文件

File configFile = new File("mbg.xml");

ConfigurationParser cp= newConfigurationParser(warnings);

Configuration config=cp.parseConfiguration(configFile);

DefaultShellCallback callback= newDefaultShellCallback(overwrite);

MyBatisGenerator myBatisGenerator= newMyBatisGenerator(config,

callback, warnings);

myBatisGenerator.generate(null);

System.out.println("運行完成....");

}

生成的文件:

總結

以上是生活随笔為你收集整理的mysql逆向工程_Mybatis+Mysql逆向工程的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網(wǎng)站內(nèi)容還不錯,歡迎將生活随笔推薦給好友。