Skip to content
This repository was archived by the owner on Feb 23, 2023. It is now read-only.

Commit ee66ec4

Browse files
committed
Add hints for HikariCP
Closes gh-1599
1 parent 942d4dc commit ee66ec4

File tree

3 files changed

+32
-0
lines changed

3 files changed

+32
-0
lines changed

samples/data-jdbc/src/main/java/com/example/data/jdbc/JdbcApplication.java

+12
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,14 @@
1515
*/
1616
package com.example.data.jdbc;
1717

18+
import javax.sql.DataSource;
19+
20+
import com.zaxxer.hikari.HikariDataSource;
21+
1822
import org.springframework.boot.SpringApplication;
1923
import org.springframework.boot.autoconfigure.SpringBootApplication;
24+
import org.springframework.boot.autoconfigure.jdbc.DataSourceProperties;
25+
import org.springframework.context.annotation.Bean;
2026
import org.springframework.data.jdbc.repository.config.EnableJdbcAuditing;
2127

2228
@SpringBootApplication
@@ -27,4 +33,10 @@ public static void main(String[] args) throws Exception {
2733
SpringApplication.run(JdbcApplication.class);
2834
Thread.currentThread().join(); // To be able to measure memory consumption
2935
}
36+
37+
@Bean
38+
// See https://github.com/spring-projects-experimental/spring-native/issues/1599
39+
public DataSource datasource(DataSourceProperties dataSourceProperties) {
40+
return dataSourceProperties.initializeDataSourceBuilder().type(HikariDataSource.class).build();
41+
}
3042
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
package com.zaxxer;
2+
3+
import java.sql.Statement;
4+
5+
import com.zaxxer.hikari.HikariDataSource;
6+
import com.zaxxer.hikari.util.ConcurrentBag.IConcurrentBagEntry;
7+
8+
import org.springframework.nativex.hint.NativeHint;
9+
import org.springframework.nativex.hint.TypeAccess;
10+
import org.springframework.nativex.hint.TypeHint;
11+
import org.springframework.nativex.type.NativeConfiguration;
12+
13+
@NativeHint(trigger = HikariDataSource.class, types = {
14+
@TypeHint(types = HikariDataSource.class, access = TypeAccess.PUBLIC_CONSTRUCTORS),
15+
@TypeHint(types = Statement[].class, access = {}),
16+
@TypeHint(types = IConcurrentBagEntry[].class, access = {})
17+
})
18+
public class HikariHints implements NativeConfiguration {
19+
}

spring-native-configuration/src/main/resources/META-INF/spring.factories

+1
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ org.mariadb.MariaDbHints,\
1919
com.mysql.cj.MySqlHints,\
2020
com.wavefront.spring.actuate.WavefrontEndpointHints,\
2121
com.wavefront.spring.actuate.WavefrontHints,\
22+
com.zaxxer.HikariHints,\
2223
org.hamcrest.HamcrestHints,\
2324
org.HdrHistogram.HdrHistogramHints,\
2425
org.hibernate.HibernateHints,\

0 commit comments

Comments
 (0)