参考地址

Exception encountered during context initialization - cancelling refresh attempt: 
org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'pmsBrandMapper'
 defined in file [G:\sq\mall\target\classes\com\macro\mall\tiny\mbg\mapper\PmsBrandMapper.class]: Unsatisfied 
 dependency expressed through bean property 'sqlSessionFactory'; nested exception is 
 org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 
 'sqlSessionFactory' defined in class path resource 
 [org/mybatis/spring/boot/autoconfigure/MybatisAutoConfiguration.class]: Unsatisfied dependency expressed 
 through method 'sqlSessionFactory' parameter 0; nested exception is 
 org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'dataSource' defined in
  class path resource [com/alibaba/druid/spring/boot/autoconfigure/DruidDataSourceAutoConfigure.class]: 
  Invocation of init method failed; nested exception is 
  org.springframework.boot.autoconfigure.jdbc.DataSourceProperties$DataSourceBeanCreationException: Failed to 
  determine a suitable driver class
  

就是这个问题困扰了我很久,一直都是没法实例化:之前查了很多资料,也不感觉有哪里错了,数据库也能连上,pom文件也设置了

<build>
		<resources>
			<resource>
				<directory>src/main/java</directory>
				<includes>
					<include>**/*.xml</include>
					<include>**/*.properties</include>
				</includes>
				<filtering>false</filtering>
			</resource>
			<resource>
				<directory>src/main/resources</directory>
				<includes>
					<include>**/*.xml</include>
					<include>**/*.properties</include>

				</includes>
				<filtering>false</filtering>
			</resource>
		</resources>
	</build>

但是怎么滴就是一直不可以正常启动,有时候也会可以启动(特别莫名其妙)
直到今天又来查资料了

在这里插入图片描述
看了下我这resources目录下有三个文件
我在pom里面只写了两个
还差一个yml文件
于是就

<build>
		<resources>
			<resource>
				<directory>src/main/java</directory>
				<includes>
					<include>**/*.xml</include>
					<include>**/*.properties</include>
					<include>**/*.yml</include>
				</includes>
				<filtering>false</filtering>
			</resource>
			<resource>
				<directory>src/main/resources</directory>
				<includes>
					<include>**/*.xml</include>
					<include>**/*.properties</include>
					<include>**/*.yml</include>
				</includes>
				<filtering>false</filtering>
			</resource>
		</resources>
	</build>

就好了具体为什么移步头部链接吧,解释的可以。

Logo

华为开发者空间,是为全球开发者打造的专属开发空间,汇聚了华为优质开发资源及工具,致力于让每一位开发者拥有一台云主机,基于华为根生态开发、创新。

更多推荐