Skip to content

Commit 2fa7939

Browse files
author
Maksim Vlasov
committed
Remove HikariCP. Add spring-boot-starter-jdbc. Add username, password and driver-class-name to the application.properties
1 parent 7894b41 commit 2fa7939

File tree

3 files changed

+8
-22
lines changed

3 files changed

+8
-22
lines changed

pom.xml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,10 @@
3333
<groupId>org.springframework.boot</groupId>
3434
<artifactId>spring-boot-starter-web</artifactId>
3535
</dependency>
36+
<dependency>
37+
<groupId>org.springframework.boot</groupId>
38+
<artifactId>spring-boot-starter-jdbc</artifactId>
39+
</dependency>
3640
<dependency>
3741
<groupId>org.springframework.boot</groupId>
3842
<artifactId>spring-boot-starter-thymeleaf</artifactId>
@@ -52,10 +56,6 @@
5256
<groupId>org.postgresql</groupId>
5357
<artifactId>postgresql</artifactId>
5458
</dependency>
55-
<dependency>
56-
<groupId>com.zaxxer</groupId>
57-
<artifactId>HikariCP</artifactId>
58-
</dependency>
5959
<dependency>
6060
<groupId>org.webjars</groupId>
6161
<artifactId>jquery</artifactId>

src/main/java/com/example/Main.java

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -38,9 +38,6 @@
3838
@SpringBootApplication
3939
public class Main {
4040

41-
@Value("${spring.datasource.url}")
42-
private String dbUrl;
43-
4441
@Autowired
4542
private DataSource dataSource;
4643

@@ -73,16 +70,4 @@ String db(Map<String, Object> model) {
7370
return "error";
7471
}
7572
}
76-
77-
@Bean
78-
public DataSource dataSource() throws SQLException {
79-
if (dbUrl == null || dbUrl.isEmpty()) {
80-
return new HikariDataSource();
81-
} else {
82-
HikariConfig config = new HikariConfig();
83-
config.setJdbcUrl(dbUrl);
84-
return new HikariDataSource(config);
85-
}
86-
}
87-
8873
}

src/main/resources/application.properties

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
1-
spring.datasource.url: ${JDBC_DATABASE_URL:}
2-
spring.datasource.hikari.connection-timeout=30000
3-
spring.datasource.hikari.maximum-pool-size=10
1+
spring.datasource.url=${JDBC_DATABASE_URL}
2+
spring.datasource.username=${DATABASE_USERNAME}
3+
spring.datasource.password=${DATABASE_PASSWORD}
4+
spring.datasource.driver-class-name=org.postgresql.Driver
45

56
spring.thymeleaf.mode=HTML
67

0 commit comments

Comments
 (0)