I actually use spring for a back-end server. I also use SpringBoot for the configuration of all this.
I also need to connect this server to a local database, for now. So I use an application.properties's file.
#Datasource
spring.datasource.url: jdbc:postgresql://localhost:5432/base_temp
spring.datasource.username: postgres
spring.datasource.password: password
spring.datasource.driverClassName: org.postgresql.Driver
#Jpa
jpa.database: POSTGRESQL
jpa.show-sql: true
jpa.hibernate.ddl-auto: create
jpa.hibernate.dialect: PostgreSQLDialect
jpa.hibernate.namingStrategy: org.hibernate.cfg.ImprovedNamingStrategy
No matter what I put, in spring.datasource.password, I don't have any error in console so I guess the file isn't load.
To solve this I've try to include this in my pom.xml
<resources>
<resource>
<directory>src/main/resources</directory>
<includes>
<include>application.properties</include>
</includes>
<filtering>true</filtering>
</resource>
</resources>
I've also try the @PropertySource or create the Datasource's @Bean myself :
@Bean
public DataSource dataSource() {
DriverManagerDataSource dataSource = new DriverManagerDataSource();
dataSource.setDriverClassName("org.postgresql.Driver");
dataSource.setUrl("jdbc:postgresql://localhost:5432/base_temp");
dataSource.setUsername("postgres");
dataSource.setPassword("password");
return dataSource;
}
But in every cases this back-end was enable to get Data from the database. I don't really know how to use SpringBoot and right know, I'm not incapable to see what's rong with my configuration.
Aucun commentaire:
Enregistrer un commentaire