Skip to content

Commit 48f1d6e

Browse files
committed
Generate proper meta-data
To avoid that the app.* keys are shown as unknown in the editor, we can enable the annotation processor. Spring Boot metadata annotation processor looks for `@ConfigurationProperties` bean on class and `@Bean` definition. For the latter it exposes the properties found on the return type of the method. Previously, we exposed `javax.sql.DataSource` that does not expose any property (getter/setter) so the meta-data for that is empty. We switched to the Tomcat connection pool to expose its relevant properties.
1 parent b585747 commit 48f1d6e

File tree

3 files changed

+10
-4
lines changed

3 files changed

+10
-4
lines changed

pom.xml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,12 @@
3838
<scope>runtime</scope>
3939
</dependency>
4040

41+
<dependency>
42+
<groupId>org.springframework.boot</groupId>
43+
<artifactId>spring-boot-configuration-processor</artifactId>
44+
<optional>true</optional>
45+
</dependency>
46+
4147
<dependency>
4248
<groupId>org.springframework.boot</groupId>
4349
<artifactId>spring-boot-starter-test</artifactId>

src/main/java/demo/customer/CustomerConfig.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
package demo.customer;
22

33
import javax.persistence.EntityManagerFactory;
4-
import javax.sql.DataSource;
54

65
import demo.customer.domain.Customer;
6+
import org.apache.tomcat.jdbc.pool.DataSource;
77

88
import org.springframework.beans.factory.annotation.Autowired;
99
import org.springframework.boot.autoconfigure.jdbc.DataSourceBuilder;
@@ -41,7 +41,7 @@ public JpaProperties customerJpaProperties() {
4141
@Primary
4242
@ConfigurationProperties(prefix = "app.customer.datasource")
4343
public DataSource customerDataSource() {
44-
return DataSourceBuilder.create().build();
44+
return (DataSource) DataSourceBuilder.create().type(DataSource.class).build();
4545
}
4646

4747
@Bean

src/main/java/demo/order/OrderConfig.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
package demo.order;
22

33
import javax.persistence.EntityManagerFactory;
4-
import javax.sql.DataSource;
54

65
import demo.order.domain.Order;
6+
import org.apache.tomcat.jdbc.pool.DataSource;
77

88
import org.springframework.beans.factory.annotation.Autowired;
99
import org.springframework.boot.autoconfigure.jdbc.DataSourceBuilder;
@@ -39,7 +39,7 @@ public JpaProperties orderJpaProperties() {
3939
@Bean
4040
@ConfigurationProperties(prefix = "app.order.datasource")
4141
public DataSource orderDataSource() {
42-
return DataSourceBuilder.create().build();
42+
return (DataSource) DataSourceBuilder.create().type(DataSource.class).build();
4343
}
4444

4545
@Bean

0 commit comments

Comments
 (0)