SprinBoot2.0+Mybatis框架搭建

起因:在公司都是现成都东西,对springboot理解没办法很深入。所以自己来搭建框架玩一玩。

参考:https://blog.csdn.net/alantuling_jt/article/details/54893383

1、在application.properties文件添加配置:

server.port = 1010
spring.datasource.url = jdbc:mysql://localhost:3306/Alexchs?characterEncoding=utf8&useSSL=true
spring.datasource.username = root
spring.datasource.password =  123456
spring.datasource.driverClassName = com.mysql.jdbc.Driver

2、搭建demo教程:http://tengj.top/2017/02/26/springboot1/

3、集成MyBatis框架,在连接数据库的时候,用到的是mysql-connector-java 6.0.5:

<mysql-connector-java.version>6.0.5</mysql-connector-java.version>

 

 

 

搭建问题记载:

  • 加载中报错:由于pom配置中parent和dependecyManagement中配置了不一样版本的相同启动依赖导致该问题。于是简单看了一下maven的scope、parent和dependencyManagement。
ERROR org.springframework.beans.factory.support.DefaultListableBeanFactory - Destroy method on bean with name 'org.springframework.boot.autoconfigure.internalCachingMetadataReaderFactory' threw an exception
  java.lang.IllegalStateException: ApplicationEventMulticaster not initialized - call 'refresh' before multicasting events via the context: org.springframework.boot.web.servlet.context.AnnotationConfigServletWebServerApplicationContext@4233e892: startup date [Thu Nov 29 16:55:00 CST 2018]; root of context hierarchy
  Error creating bean with name 'org.springframework.context.annotation.internalConfigurationAnnotationProcessor'
<parent>
		<!--C:\Users\用户.m2\repository\org\springframework\boot\spring-boot-dependencies\1.5.1.RELEASE\spring-boot-dependencies-1.5.1.RELEASE.pom-->
		<groupId>org.springframework.boot</groupId>
		<artifactId>spring-boot-starter-parent</artifactId>
		<version>2.0.4.RELEASE</version>
		<relativePath/> <!-- lookup parent from repository -->
	</parent>

	<dependencyManagement>
		<dependencies>
			<!-- Override Spring Data release train provided by Spring Boot -->
			<!--<dependency>-->
				<!--<groupId>org.springframework.data</groupId>-->
				<!--<artifactId>spring-data-releasetrain</artifactId>-->
				<!--<version>Fowler-SR2</version>-->
				<!--<scope>import</scope>-->
				<!--<type>pom</type>-->
			<!--</dependency>-->
			<!--<dependency>-->
				<!--<groupId>org.springframework.boot</groupId>-->
				<!--<artifactId>spring-boot-dependencies</artifactId>-->
				<!--<version>1.5.1.RELEASE</version>-->
				<!--<type>pom</type>-->
				<!--<scope>import</scope>-->
			<!--</dependency>-->
		</dependencies>
	</dependencyManagement>

       需要在Application.class添加@EnableSwagger2注解

 

 

 

 

 

blog问题:

1、插入代码本身

2、过于简略

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值