***************************
APPLICATION FAILED TO START
***************************
Description:
Failed to auto-configure a DataSource: 'spring.datasource.url' is not specified and no embedded datasource could be auto-configured.
Reason: Failed to determine a suitable driver class
Action:
Consider the following:
If you want an embedded database (H2, HSQL or Derby), please put it on the classpath.
If you have database settings to be loaded from a particular profile you may need to activate it (no profiles are currently active).
Process finished with exit code 1
在使用IDEA整合spring cloud项目时,为了测试负载均衡及提供者与使用者通信是否能够成功的时,所以先创建了一个提供者producer1,并且整合了mybatis和druid,测试成功后,直接复制了producer1粘贴了一个producer2出来,然后改了下项目名和pom的项目名后,当我要测试FeignClient的负载均衡时,启动producer2时,发现注册中心,producer2没有注册进去,在仔细看日志,发现出现了如上错误。奇怪,一模一样的 咋就出现差异了??,顺便对比了下modules里producer1、producer2的spring配置,乍一看 没错,准备关掉的时候,发现突然发现不一样:如下:
突然发现producer2下面没有这个,这丫不是更本没找到配置文件嘛··。
然后就发现我的resource文件夹idea没有标示为resource特有的文件夹 ,尴尬。在选中resource右键make directory as =>resource后,在启动就可以了,这只是其中一种解决办法哈,顺便贴个别人的 这里供参考。
另外注意spring boot 配置文件在resource设置正确的情况下,会显示成绿色树叶的图标。这样,主要还是之前没有特别留意到这个配置没有变成这种图标。
顺便在贴一个我的pom配置,并没有注释掉pom里的东西,也没有在启动类上加东西。
解决的话 留下赞?
<properties>
<java.version>1.8</java.version>
<spring-cloud.version>Greenwich.SR1</spring-cloud.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-netflix-eureka-server</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-autoconfigure</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-commons</artifactId>
<version>RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<!-- 数据库连接 -->
<!-- https://mvnrepository.com/artifact/mysql/mysql-connector-java -->
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>8.0.15</version>
</dependency>
<!-- 连接池 -->
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>druid</artifactId> <!--druid-spring-boot-starter-->
<version>1.1.10</version>
</dependency>
<dependency>
<groupId>org.mybatis</groupId>
<artifactId>mybatis-spring</artifactId>
<version>2.0.0</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.mybatis.spring.boot</groupId>
<artifactId>mybatis-spring-boot-starter</artifactId>
<version>2.0.0</version>
</dependency>