UPDATE:
I realized a couple of things now. My application.properties file is being loaded properly because I verified via the /env path (thanks Dave) that my DB properties are being loaded. The problem appears to be that when I run it using the Spring Boot maven plug-in, it fails to initialize my dataSource.
mvn spring-boot:run
This then causes my application to blow-up with errors because other beans can't get initialized. The odd thing is it runs fine from Eclipse.
I have a class called DataService that extends JdbcTemplate. In my DataService constructor, I inject the DataSource.
@Component
public class DataService extends JdbcTemplate {
@Autowired
public DataService(DataSource dataSource){
super(dataSource);
}
...more custom methods
}
I use this DataService class in other beans to perform DB operations. My DataSource is defined in my application.properties file
spring.datasource.url: jdbc:h2:tcp://localhost/~/testdb2
spring.datasource.driverClassName: org.h2.Driver
This is my Application.java class
@Configuration
@ComponentScan
@EnableAutoConfiguration
@EnableWebMvcSecurity
@EnableAsync
@EnableScheduling
public class Application {
public static void main(String[] args) {
SpringApplication.run(Application.class, args);
}
}
I first realized this when I was attempting to run jUnit tests from Maven using
mavent test
I thought it just had to do with how it was executing the jUnit test cases however it is also occurring when I simply try to run the application using maven.
My JUnit4 test class is defined as follows:
@RunWith(SpringJUnit4ClassRunner.class)
@SpringApplicationConfiguration(classes={Application.class})
@WebAppConfiguration
public class QuestionRepositoryIntegrationTests {
...methods
}
I used the example from the Spring Boot how-to docs (https://docs.spring.io/spring-boot/docs/current/reference/html/howto.html)
When I run this JUnit class from Eclipse, it works just fine. When it executes from maven, it starts to act up as I described above.
spring.datasource.hibernate.ddl-auto=none(otherwise using tcp for an H" database could lead to grief)?application.propertiesresolution that we fixed since RC3 (it doesn't seem relevant, but it might be). Otherwise, if you can share your complete project (or a simple project with the same problem) and a nice README to tell me how to create the database, I can take a look.DataSourcecan't do (it works for me in production). So we still need to try and understand why it wasn't working for you. The banner has nothing to do with properties files. The best thing you can do might be to add the actuator as a dependency (if you haven't already) and look at the /env endpoint (where you will see all the environment properties and their sources).