1
0
forked from PGL/Clyde

adding database support

This commit is contained in:
2024-02-27 12:08:28 +01:00
parent c0ab074a95
commit 88108918dd
4 changed files with 34 additions and 15 deletions

View File

@ -16,17 +16,17 @@ repositories {
}
dependencies {
// implementation("org.springframework.boot:spring-boot-starter-jdbc")
implementation("org.springframework.boot:spring-boot-starter-jdbc")
implementation("org.springframework.boot:spring-boot-starter-mail")
implementation("org.springframework.boot:spring-boot-starter-web")
// implementation("org.springframework.session:spring-session-jdbc")
implementation("org.springframework.session:spring-session-jdbc")
developmentOnly("org.springframework.boot:spring-boot-devtools")
// developmentOnly("org.springframework.boot:spring-boot-docker-compose")
developmentOnly("org.springframework.boot:spring-boot-docker-compose")
runtimeOnly("org.postgresql:postgresql")
testImplementation("org.springframework.boot:spring-boot-starter-test")
// testImplementation("org.springframework.boot:spring-boot-testcontainers")
// testImplementation("org.testcontainers:junit-jupiter")
// testImplementation("org.testcontainers:postgresql")
testImplementation("org.springframework.boot:spring-boot-testcontainers")
testImplementation("org.testcontainers:junit-jupiter")
testImplementation("org.testcontainers:postgresql")
}
tasks.register("run") {

View File

@ -1,13 +1,9 @@
services:
backend:
build: .
ports:
- 4000:8080
postgres:
image: 'postgres:latest'
environment:
- 'POSTGRES_DB=mydatabase'
- 'POSTGRES_PASSWORD=secret'
- 'POSTGRES_USER=myuser'
- 'POSTGRES_DB=clyde'
- 'POSTGRES_USER=devel'
- 'POSTGRES_PASSWORD=devel'
ports:
- '5432'
- '5432:5432'

View File

@ -0,0 +1,23 @@
package ovh.herisson.Clyde;
import javax.sql.DataSource;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.jdbc.datasource.DriverManagerDataSource;
@Configuration
public class JdbcConfig {
@Bean
public DataSource psqlSource(){
DriverManagerDataSource source = new DriverManagerDataSource();
source.setDriverClassName("org.postgresql.Driver");
source.setUrl("jdbc:postgresql://localhost:5432/clyde");
source.setUsername("devel");
source.setPassword("devel");
return source;
}
}