Spring Boot not reading application.properties for DataSource

springspring-boot

I've put my DataSource details in /resources/application.properties file:

spring.datasource.url = jdbc:mysql://localhost:3306/dsm
spring.datasource.username = root
spring.datasource.password = admin123
spring.datasource.testWhileIdle = true
spring.datasource.validationQuery = SELECT 1

spring.jpa.show-sql = true
spring.jpa.hibernate.ddl-auto = update
spring.jpa.hibernate.naming-strategy = org.hibernate.cfg.ImprovedNamingStrategy

spring.jpa.properties.hibernate.dialect = org.hibernate.dialect.MySQL5Dialect

I've tried adding a direct reference to the properties file, this this didn't make any difference.

@PropertySource("classpath:application.properties")

The error being generated is:

2015-11-23 14:44:30.232  INFO 54329 --- [on(2)-127.0.0.1] o.s.b.c.embedded.FilterRegistrationBean  : Mapping filter: 'requestContextFilter' to: [/*]
2015-11-23 14:44:31.522  INFO 54329 --- [on(2)-127.0.0.1] j.LocalContainerEntityManagerFactoryBean : Building JPA container EntityManagerFactory for persistence unit 'default'
2015-11-23 14:44:31.535  INFO 54329 --- [on(2)-127.0.0.1] o.hibernate.jpa.internal.util.LogHelper  : HHH000204: Processing PersistenceUnitInfo [
    name: default
    ...]
2015-11-23 14:44:31.629  INFO 54329 --- [on(2)-127.0.0.1] org.hibernate.Version                    : HHH000412: Hibernate Core {4.3.11.Final}
2015-11-23 14:44:31.632  INFO 54329 --- [on(2)-127.0.0.1] org.hibernate.cfg.Environment            : HHH000206: hibernate.properties not found
2015-11-23 14:44:31.636  INFO 54329 --- [on(2)-127.0.0.1] org.hibernate.cfg.Environment            : HHH000021: Bytecode provider name : javassist
2015-11-23 14:44:31.824  INFO 54329 --- [on(2)-127.0.0.1] o.hibernate.annotations.common.Version   : HCANN000001: Hibernate Commons Annotations {4.0.5.Final}
23-Nov-2015 14:44:32.005 WARNING [RMI TCP Connection(2)-127.0.0.1] org.apache.tomcat.jdbc.pool.PooledConnection.connectUsingDriver Not loading a JDBC driver as driverClassName property is null.
23-Nov-2015 14:44:32.008 SEVERE [RMI TCP Connection(2)-127.0.0.1] org.apache.tomcat.jdbc.pool.ConnectionPool.init Unable to create initial connections of pool.
 java.sql.SQLException: The url cannot be null

Looking at my properties file, both the dialect and the url are defined, and they're not being picked up, which is leading me to believe that the file isn't being ready.

My application class incase it helps:

@SpringBootApplication
public class Application extends SpringBootServletInitializer {

    public static void main(String[] args) {
        ApplicationContext ctx = SpringApplication.run(Application.class, args);
    }

}

Best Answer

It turns out the problem was that Intellj was deploying classes and files to TomCat which had previous been deleted.

I cleared the 'target' folder in IntellJ and redeployed.