解决The import org.springframework.boot.jdbc.DataSourceBuilder cannot be resolved的问题。

问题

    在研究SpringBoot事务,跑一个网上的例子时,报错:

The import org.springframework.boot.jdbc.DataSourceBuilder cannot be resolved。

分析

由于已经导入SpringBoot相关包,所以,初步怀疑是SpringBoot的版本问题导致。

当前pom.xml文件

<parent>
		<groupId>org.springframework.boot</groupId>
		<artifactId>spring-boot-starter-parent</artifactId>
		<version>1.5.18.RELEASE</version>
		<relativePath /> <!-- lookup parent from repository -->
	</parent>

查找了一下SpringBoot官方文档,发现本地定义SpringBoot版本太低导致。

该类在SpringBoot 2.0.0才出现。

解决

    最简单的解决方法是直接把pom.xml文件中的版本提高到2.0.0.

   <parent>
		<groupId>org.springframework.boot</groupId>
		<artifactId>spring-boot-starter-parent</artifactId>
		<version>2.0.0.RELEASE</version>
		<relativePath /> 
	</parent>

文章结束。

猜你喜欢

转载自blog.csdn.net/cysunc/article/details/86473448