Properties in my application.properties file are greyed out, i get Failed to configure a DataSource: 'url' attribute is not specified

Jay_Pixel :

Failed to configure a DataSource: 'url' attribute is not specified and no embedded datasource could be configured.

Hi all, I get the below error when i run my application in intelij trying to connect to mysql

2019-09-27 13:26:52.644  WARN 1084 --- [  restartedMain] ConfigServletWebServerApplicationContext : Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'inMemoryDatabaseShutdownExecutor' defined in class path resource [org/springframework/boot/devtools/autoconfigure/DevToolsDataSourceAutoConfiguration.class]: Unsatisfied dependency expressed through method 'inMemoryDatabaseShutdownExecutor' parameter 0; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'dataSource' defined in class path resource [org/springframework/boot/autoconfigure/jdbc/DataSourceConfiguration$Hikari.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [com.zaxxer.hikari.HikariDataSource]: Factory method 'dataSource' threw exception; nested exception is org.springframework.boot.autoconfigure.jdbc.DataSourceProperties$DataSourceBeanCreationException: Failed to determine a suitable driver class
2019-09-27 13:26:52.648  INFO 1084 --- [  restartedMain] o.apache.catalina.core.StandardService   : Stopping service [Tomcat]
2019-09-27 13:26:52.671  INFO 1084 --- [  restartedMain] ConditionEvaluationReportLoggingListener : 

Error starting ApplicationContext. To display the conditions report re-run your application with 'debug' enabled.
2019-09-27 13:26:52.674 ERROR 1084 --- [  restartedMain] o.s.b.d.LoggingFailureAnalysisReporter   : 

***************************
APPLICATION FAILED TO START
***************************

Description:

Failed to configure a DataSource: 'url' attribute is not specified and no embedded datasource could be 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 0

I have added the following to my application.properties file in the resources folder

server.port = 8080
spring.servlet.multipart.enabled = false;

spring.jpa.hibernate.ddl-auto = update

spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver
spring.datasource.url = jdbc:mysql://localhost:3306/invoice
spring.datasource.username = root
spring.datasource.password = password

when i look at my application.properties file i notice that my properties are unused. screenshot

this is my pom.xml file

<?xml version="1.0" encoding="UTF-8"?>

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
  <modelVersion>4.0.0</modelVersion>

  <groupId>com.jade</groupId>
  <artifactId>invoicesystem</artifactId>
  <version>1.0-SNAPSHOT</version>

  <!-- 1 To convert to springboot application the 1st thing to add is the parent below-->
  <parent>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-parent</artifactId>
    <version>2.1.5.RELEASE</version>
  </parent>

  <name>invoicesystem</name>
  <!-- FIXME change it to the project's website -->
  <url>http://www.example.com</url>




  <properties>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    <maven.compiler.source>1.7</maven.compiler.source>
    <maven.compiler.target>1.7</maven.compiler.target>
  </properties>

  <dependencies>

    <!--2 To convert to springboot application the 2nd thing to do, add dependency: spring-boot-starter-web-->
    <dependency>
      <groupId>org.springframework.boot</groupId>
      <artifactId>spring-boot-starter-web</artifactId>
      <version>2.1.5.RELEASE</version>
    </dependency>

    <dependency>
      <groupId>org.springframework.boot</groupId>
      <artifactId>spring-boot-devtools</artifactId>
      <version>2.1.4.RELEASE</version>
      <optional>true</optional>
    </dependency>

    <dependency>
      <groupId>org.springframework.boot</groupId>
      <artifactId>spring-boot-starter-security</artifactId>
    </dependency>

    <dependency>
      <groupId>org.springframework.boot</groupId>
      <artifactId>spring-boot-starter-test</artifactId>
      <version>2.1.4.RELEASE</version>
      <scope>test</scope>
    </dependency>

    <dependency>
      <groupId>org.springframework.boot</groupId>
      <artifactId>spring-boot-starter-data-jpa</artifactId>
    </dependency>

    <dependency>
      <groupId>mysql</groupId>
      <artifactId>mysql-connector-java</artifactId>
    </dependency>

  </dependencies>

  <build>
    <pluginManagement><!-- lock down plugins versions to avoid using Maven defaults (may be moved to parent pom) -->
      <plugins>
        <!-- clean lifecycle, see https://maven.apache.org/ref/current/maven-core/lifecycles.html#clean_Lifecycle -->
        <plugin>
          <artifactId>maven-clean-plugin</artifactId>
          <version>3.1.0</version>
        </plugin>
        <!-- default lifecycle, jar packaging: see https://maven.apache.org/ref/current/maven-core/default-bindings.html#Plugin_bindings_for_jar_packaging -->
        <plugin>
          <artifactId>maven-resources-plugin</artifactId>
          <version>3.0.2</version>
        </plugin>
        <plugin>
          <artifactId>maven-compiler-plugin</artifactId>
          <version>3.8.0</version>
        </plugin>
        <plugin>
          <artifactId>maven-surefire-plugin</artifactId>
          <version>2.22.1</version>
        </plugin>
        <plugin>
          <artifactId>maven-jar-plugin</artifactId>
          <version>3.0.2</version>
        </plugin>
        <plugin>
          <artifactId>maven-install-plugin</artifactId>
          <version>2.5.2</version>
        </plugin>
        <plugin>
          <artifactId>maven-deploy-plugin</artifactId>
          <version>2.8.2</version>
        </plugin>
        <!-- site lifecycle, see https://maven.apache.org/ref/current/maven-core/lifecycles.html#site_Lifecycle -->
        <plugin>
          <artifactId>maven-site-plugin</artifactId>
          <version>3.7.1</version>
        </plugin>
        <plugin>
          <artifactId>maven-project-info-reports-plugin</artifactId>
          <version>3.0.0</version>
        </plugin>
      </plugins>
    </pluginManagement>
    <plugins>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-compiler-plugin</artifactId>
        <configuration>
          <source>8</source>
          <target>8</target>
        </configuration>
      </plugin>
    </plugins>
  </build>
</project>
Jay_Pixel :

so after much deliberation, i decided to have a look at my resource folder, and the application.properties file and turns out that the resources directory was not marked as resources root, by right-clicking on the resource folder directory, hover over Mark Directory as and select Resources Root screenshot

Sorry for wasting everyones time, and thanks for all the help as i did use some of the configs mentioned

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

Failed to configure a DataSource: 'url' attribute is not specified and no embedded datasource could be configured

Failed to configure a DataSource: 'url' attribute is not specified using Spring Boot

Spring Boot: Failed to configure a DataSource: 'url' attribute is not specified and no embedded datasource could be configured

Failed to configure a DataSource: 'url' attribute is not specified and no embedded datasource could be configured. SPRING

Config-Server Failed to configure a DataSource: 'url' attribute is not specified and no embedded datasource could be configured

Gradle project --Failed to configure a DataSource'url' attribute is not specified and no embedded datasource could be configured

Failed to configure a DataSource: 'url' attribute is not specified and no embedded datasource could be configured.Error In Gradle project

Failed to configure a DataSource: 'url' attribute is not specified and no embedded datasource could be configured. Reason: Fa

Spring Boot jdbc issue. Failed to configure a DataSource: 'url' attribute is not specified and no embedded datasource could be configured

Spring Framework: Failed to configure a DataSource: 'url' attribute is not specified and no embedded datasource could be configured

Failed to configure a DataSource: 'url' attribute is not specified and no embedded datasource could be configured for MongoDb

Failed to auto-configure a DataSource: 'spring.datasource.url' is not specified

Failed to auto-configure a DataSource: 'spring.datasource.url' is not specified

Failed to configure a DataSource: 'url'

Can I configure a @FeignClient url using a properties/yml file?

spring boot: how to configure datasource from application properties

How can I get the sum of the properties in the datasource?

How do I configure HikariCP in my Spring Boot app in my application.properties files?

How to add datasource url query parameters as application.properties?

How can I use properties from a configuration (properties/yml) file in my Spring Boot application?

SpringBoot2 Failed to auto-configure a DataSource: 'spring.datasource.url' is not specified and no embedded datasource could be auto-configured

How do I use a configuration class to configure properties for my application in Spring Boot?

Configure VPN... is greyed out and I cannot edit my VPN settings

What is datasource.url and datasource.driverClassName in application.properties in Spring Boot

'url' attribute is not specified and no embedded datasource could be configured. Failed to determine a suitable driver class

Spring - How to configure OracleDataSource from spring.datasource in application.properties

'url' attribute is not specified and no embedded datasource could be configured

How do I specify local file path to my ssl keystore file in spring application.properties?

Update spring boot datasource properties on application startup