SpringBoot+Mybatis+Druid+Mysql(Oracle)多数据源监控配置框架搭建

看了网上很多关于SpringBoot+Mybatis+Druid+Mysql(Oracle)多数据源监控配置demo,但是始终不能找到一个合适并且完整的搭建过程,以及分析下搭建demo的问题。

配置

1.项目结构

config目录下是demo主要的配置

2.pom.xml文件中引入依赖

    <!-- springboot版本依赖 1.4.1.RELEASE-->
	<parent>
		<groupId>org.springframework.boot</groupId>
		<artifactId>spring-boot-starter-parent</artifactId>
		<version>1.5.8.RELEASE</version>
	</parent>

	<properties>
		<!--<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> -->
		<!-- jdk1.8以上这里一定要配置上java的版本,如果是1.7版本的可不用配置 -->
	</properties>
	<dependencies>
		<!-- springboot核心包-->
		<dependency>
			<groupId>org.springframework.boot</groupId>
			<artifactId>spring-boot-starter-web</artifactId>
		</dependency>
		<dependency>
			<groupId>org.springframework.boot</groupId>
			<artifactId>spring-boot-starter-thymeleaf</artifactId>
		</dependency>
		<dependency>
			<groupId>org.mybatis.spring.boot</groupId>
			<artifactId>mybatis-spring-boot-starter</artifactId>
			<version>1.3.2</version>
		</dependency>
		<dependency>
		    <groupId>com.oracle</groupId>
		    <artifactId>ojdbc6</artifactId>
		    <version>11.2.0.3</version>
		</dependency>
		<dependency>
			<groupId>org.springframework.boot</groupId>
			<artifactId>spring-boot-starter-jdbc</artifactId>
		</dependency>
		<dependency>
			<groupId>mysql</groupId>
			<artifactId>mysql-connector-java</artifactId>
		</dependency>
		<dependency>
			<groupId>com.alibaba</groupId>
			<artifactId>druid-spring-boot-starter</artifactId>
			<version>1.1.10</version>
		</dependency>
		<dependency>
		    <groupId>com.github.pagehelper</groupId>
		    <artifactId>pagehelper</artifactId>
		    <version>4.1.6</version>
		</dependency>
		
		<!-- springboot-aop包,AOP切面注解,Aspectd等相关注解 -->
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-aop</artifactId>
        </dependency>

      2.1关键的依赖包版本dmeo中适配中可能会碰到的问题

  1. ojdbc6 包与 druid 包匹配,经过demo检验不会出现程序异常的问题
  2. 引用druid-spring-boot-starter 而不是 druid 包 ,此处包出错的话,会导致程序可以正常启动,但是Druid SQL Stat无法监控到SQL
  3. mysql 包 与druid 包,引用demo的版本可正常启动
  4. druid-spring-boot-starter 包 demo版本比较新

3.修改src/main/resources/application.properties文件

#servername
server.context-path=/zhpt
#thymeleaf
spring.thymeleaf.cache=false
spring.thymeleaf.content-type=text/html
spring.thymeleaf.enabled=true
spring.thymeleaf.mode=HTML5
spring.thymeleaf.encoding=UTF-8
spring.thymeleaf.prefix=classpath:/templates/
spring.thymeleaf.suffix=.html
#mybatis
mybatis.type-aliases-package=com.erxi.ms.domain
mybatis.configuration.map-underscore-to-camel-case=true
mybatis.configuration.default-fetch-size=100
mybatis.configuration.default-statement-timeout=3000
mybatis.mapperLocations=classpath:com/erxi/ms/dao/*.xml
#druid
spring.datasource.type=com.alibaba.druid.poo
  • 0
    点赞
  • 5
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值