Skip to content

Commit

Permalink
Generate proper meta-data
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
snicoll committed Aug 7, 2015
1 parent b585747 commit 48f1d6e
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 4 deletions.
6 changes: 6 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,12 @@
<scope>runtime</scope>
</dependency>

<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-configuration-processor</artifactId>
<optional>true</optional>
</dependency>

<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/demo/customer/CustomerConfig.java
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
package demo.customer;

import javax.persistence.EntityManagerFactory;
import javax.sql.DataSource;

import demo.customer.domain.Customer;
import org.apache.tomcat.jdbc.pool.DataSource;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.jdbc.DataSourceBuilder;
Expand Down Expand Up @@ -41,7 +41,7 @@ public JpaProperties customerJpaProperties() {
@Primary
@ConfigurationProperties(prefix = "app.customer.datasource")
public DataSource customerDataSource() {
return DataSourceBuilder.create().build();
return (DataSource) DataSourceBuilder.create().type(DataSource.class).build();
}

@Bean
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/demo/order/OrderConfig.java
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
package demo.order;

import javax.persistence.EntityManagerFactory;
import javax.sql.DataSource;

import demo.order.domain.Order;
import org.apache.tomcat.jdbc.pool.DataSource;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.jdbc.DataSourceBuilder;
Expand Down Expand Up @@ -39,7 +39,7 @@ public JpaProperties orderJpaProperties() {
@Bean
@ConfigurationProperties(prefix = "app.order.datasource")
public DataSource orderDataSource() {
return DataSourceBuilder.create().build();
return (DataSource) DataSourceBuilder.create().type(DataSource.class).build();
}

@Bean
Expand Down

0 comments on commit 48f1d6e

Please sign in to comment.