From 387282af4a89a71e5d3039b0e7a4113473da6878 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Edd=C3=BA=20Mel=C3=A9ndez?= Date: Tue, 16 Dec 2025 17:52:50 -0600 Subject: [PATCH] Fix configuration processor MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit As stated in the docs https://docs.spring.io/spring-boot/specification/configuration-metadata/annotation-processor.html. It should be added to maven-compiler-plugin's configuration. Signed-off-by: Eddú Meléndez --- pom.xml | 4 ++++ .../ai/vectorstore/mariadb/MariaDBStoreIT.java | 16 ++++++---------- .../mariadb/MariaDBStoreObservationIT.java | 15 +++++++-------- .../vectorstore/oracle/OracleVectorStoreIT.java | 10 +++++----- .../oracle/OracleVectorStoreObservationIT.java | 15 ++++++--------- .../pgvector/PgVectorStoreCustomNamesIT.java | 16 ++++++---------- .../ai/vectorstore/pgvector/PgVectorStoreIT.java | 11 ++++++----- .../pgvector/PgVectorStoreObservationIT.java | 11 ++++++----- 8 files changed, 46 insertions(+), 52 deletions(-) diff --git a/pom.xml b/pom.xml index d635acace66..92b5c499bbb 100644 --- a/pom.xml +++ b/pom.xml @@ -477,6 +477,10 @@ nullaway ${nullaway.version} + + org.springframework.boot + spring-boot-configuration-processor + diff --git a/vector-stores/spring-ai-mariadb-store/src/test/java/org/springframework/ai/vectorstore/mariadb/MariaDBStoreIT.java b/vector-stores/spring-ai-mariadb-store/src/test/java/org/springframework/ai/vectorstore/mariadb/MariaDBStoreIT.java index f9e5456d3af..890cabf64f1 100644 --- a/vector-stores/spring-ai-mariadb-store/src/test/java/org/springframework/ai/vectorstore/mariadb/MariaDBStoreIT.java +++ b/vector-stores/spring-ai-mariadb-store/src/test/java/org/springframework/ai/vectorstore/mariadb/MariaDBStoreIT.java @@ -53,13 +53,11 @@ import org.springframework.beans.factory.annotation.Value; import org.springframework.boot.SpringBootConfiguration; import org.springframework.boot.autoconfigure.EnableAutoConfiguration; -import org.springframework.boot.context.properties.ConfigurationProperties; import org.springframework.boot.jdbc.autoconfigure.DataSourceAutoConfiguration; import org.springframework.boot.jdbc.autoconfigure.DataSourceProperties; import org.springframework.boot.test.context.runner.ApplicationContextRunner; import org.springframework.context.ApplicationContext; import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Primary; import org.springframework.core.io.DefaultResourceLoader; import org.springframework.jdbc.core.JdbcTemplate; import org.springframework.util.CollectionUtils; @@ -70,6 +68,7 @@ /** * @author Diego Dupin * @author Soby Chacko + * @author Eddú Meléndez */ @Testcontainers @EnabledIfEnvironmentVariable(named = "OPENAI_API_KEY", matches = ".+") @@ -87,11 +86,6 @@ public class MariaDBStoreIT extends BaseVectorStoreTests { private final ApplicationContextRunner contextRunner = new ApplicationContextRunner() .withUserConfiguration(TestApplication.class) .withPropertyValues("test.spring.ai.vectorstore.mariadb.distanceType=COSINE", - - // JdbcTemplate configuration - String.format("app.datasource.url=jdbc:mariadb://%s:%d/%s?maxQuerySizeToLog=50000", - mariadbContainer.getHost(), mariadbContainer.getMappedPort(3306), schemaName), - "app.datasource.username=mariadb", "app.datasource.password=mariadbpwd", "app.datasource.type=com.zaxxer.hikari.HikariDataSource"); List documents = List.of( @@ -432,10 +426,12 @@ public JdbcTemplate myJdbcTemplate(DataSource dataSource) { } @Bean - @Primary - @ConfigurationProperties("app.datasource") public DataSourceProperties dataSourceProperties() { - return new DataSourceProperties(); + DataSourceProperties properties = new DataSourceProperties(); + properties.setUrl(mariadbContainer.getJdbcUrl()); + properties.setUsername(mariadbContainer.getUsername()); + properties.setPassword(mariadbContainer.getPassword()); + return properties; } @Bean diff --git a/vector-stores/spring-ai-mariadb-store/src/test/java/org/springframework/ai/vectorstore/mariadb/MariaDBStoreObservationIT.java b/vector-stores/spring-ai-mariadb-store/src/test/java/org/springframework/ai/vectorstore/mariadb/MariaDBStoreObservationIT.java index 9451a1c4041..1613d3648ac 100644 --- a/vector-stores/spring-ai-mariadb-store/src/test/java/org/springframework/ai/vectorstore/mariadb/MariaDBStoreObservationIT.java +++ b/vector-stores/spring-ai-mariadb-store/src/test/java/org/springframework/ai/vectorstore/mariadb/MariaDBStoreObservationIT.java @@ -47,12 +47,10 @@ import org.springframework.ai.vectorstore.observation.VectorStoreObservationDocumentation.LowCardinalityKeyNames; import org.springframework.boot.SpringBootConfiguration; import org.springframework.boot.autoconfigure.EnableAutoConfiguration; -import org.springframework.boot.context.properties.ConfigurationProperties; import org.springframework.boot.jdbc.autoconfigure.DataSourceAutoConfiguration; import org.springframework.boot.jdbc.autoconfigure.DataSourceProperties; import org.springframework.boot.test.context.runner.ApplicationContextRunner; import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Primary; import org.springframework.core.io.DefaultResourceLoader; import org.springframework.jdbc.core.JdbcTemplate; @@ -60,6 +58,7 @@ /** * @author Diego Dupin + * @author Eddú Meléndez */ @EnabledIfEnvironmentVariable(named = "OPENAI_API_KEY", matches = ".+") @Testcontainers @@ -77,9 +76,7 @@ public class MariaDBStoreObservationIT { private final ApplicationContextRunner contextRunner = new ApplicationContextRunner() .withUserConfiguration(Config.class) .withPropertyValues("test.spring.ai.vectorstore.mariadb.distanceType=COSINE", - // JdbcTemplate configuration - "app.datasource.url=" + mariadbContainer.getJdbcUrl(), "app.datasource.username=mariadb", - "app.datasource.password=mariadbpwd", "app.datasource.type=com.zaxxer.hikari.HikariDataSource"); + "app.datasource.type=com.zaxxer.hikari.HikariDataSource"); List documents = List.of( new Document(getText("classpath:/test/data/spring.ai.txt"), Map.of("meta1", "meta1")), @@ -190,10 +187,12 @@ public JdbcTemplate myJdbcTemplate(DataSource dataSource) { } @Bean - @Primary - @ConfigurationProperties("app.datasource") public DataSourceProperties dataSourceProperties() { - return new DataSourceProperties(); + DataSourceProperties properties = new DataSourceProperties(); + properties.setUrl(mariadbContainer.getJdbcUrl()); + properties.setUsername(mariadbContainer.getUsername()); + properties.setPassword(mariadbContainer.getPassword()); + return properties; } @Bean diff --git a/vector-stores/spring-ai-oracle-store/src/test/java/org/springframework/ai/vectorstore/oracle/OracleVectorStoreIT.java b/vector-stores/spring-ai-oracle-store/src/test/java/org/springframework/ai/vectorstore/oracle/OracleVectorStoreIT.java index 1c886bcbda9..dfa755fe1cf 100644 --- a/vector-stores/spring-ai-oracle-store/src/test/java/org/springframework/ai/vectorstore/oracle/OracleVectorStoreIT.java +++ b/vector-stores/spring-ai-oracle-store/src/test/java/org/springframework/ai/vectorstore/oracle/OracleVectorStoreIT.java @@ -53,13 +53,11 @@ import org.springframework.beans.factory.annotation.Value; import org.springframework.boot.SpringBootConfiguration; import org.springframework.boot.autoconfigure.EnableAutoConfiguration; -import org.springframework.boot.context.properties.ConfigurationProperties; import org.springframework.boot.jdbc.autoconfigure.DataSourceAutoConfiguration; import org.springframework.boot.jdbc.autoconfigure.DataSourceProperties; import org.springframework.boot.test.context.runner.ApplicationContextRunner; import org.springframework.context.ApplicationContext; import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Primary; import org.springframework.core.io.DefaultResourceLoader; import org.springframework.jdbc.core.JdbcTemplate; import org.springframework.util.CollectionUtils; @@ -412,10 +410,12 @@ public JdbcTemplate myJdbcTemplate(DataSource dataSource) { } @Bean - @Primary - @ConfigurationProperties("app.datasource") public DataSourceProperties dataSourceProperties() { - return new DataSourceProperties(); + DataSourceProperties properties = new DataSourceProperties(); + properties.setUrl(oracle23aiContainer.getJdbcUrl()); + properties.setUsername(oracle23aiContainer.getUsername()); + properties.setPassword(oracle23aiContainer.getPassword()); + return properties; } @Bean diff --git a/vector-stores/spring-ai-oracle-store/src/test/java/org/springframework/ai/vectorstore/oracle/OracleVectorStoreObservationIT.java b/vector-stores/spring-ai-oracle-store/src/test/java/org/springframework/ai/vectorstore/oracle/OracleVectorStoreObservationIT.java index 13c3f318d28..169dab3047e 100644 --- a/vector-stores/spring-ai-oracle-store/src/test/java/org/springframework/ai/vectorstore/oracle/OracleVectorStoreObservationIT.java +++ b/vector-stores/spring-ai-oracle-store/src/test/java/org/springframework/ai/vectorstore/oracle/OracleVectorStoreObservationIT.java @@ -49,13 +49,11 @@ import org.springframework.ai.vectorstore.oracle.OracleVectorStore.OracleVectorStoreDistanceType; import org.springframework.boot.SpringBootConfiguration; import org.springframework.boot.autoconfigure.EnableAutoConfiguration; -import org.springframework.boot.context.properties.ConfigurationProperties; import org.springframework.boot.jdbc.autoconfigure.DataSourceAutoConfiguration; import org.springframework.boot.jdbc.autoconfigure.DataSourceProperties; import org.springframework.boot.test.context.runner.ApplicationContextRunner; import org.springframework.context.ApplicationContext; import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Primary; import org.springframework.core.io.DefaultResourceLoader; import org.springframework.jdbc.core.JdbcTemplate; @@ -64,6 +62,7 @@ /** * @author Christian Tzolov * @author Thomas Vitale + * @author Eddú Meléndez */ @Testcontainers public class OracleVectorStoreObservationIT { @@ -79,10 +78,6 @@ public class OracleVectorStoreObservationIT { private final ApplicationContextRunner contextRunner = new ApplicationContextRunner() .withUserConfiguration(Config.class) .withPropertyValues("test.spring.ai.vectorstore.oracle.dimensions=384", - // JdbcTemplate configuration - String.format("app.datasource.url=%s", oracle23aiContainer.getJdbcUrl()), - String.format("app.datasource.username=%s", oracle23aiContainer.getUsername()), - String.format("app.datasource.password=%s", oracle23aiContainer.getPassword()), "app.datasource.type=oracle.jdbc.pool.OracleDataSource"); List documents = List.of( @@ -213,10 +208,12 @@ public JdbcTemplate myJdbcTemplate(DataSource dataSource) { } @Bean - @Primary - @ConfigurationProperties("app.datasource") public DataSourceProperties dataSourceProperties() { - return new DataSourceProperties(); + DataSourceProperties properties = new DataSourceProperties(); + properties.setUrl(oracle23aiContainer.getJdbcUrl()); + properties.setUsername(oracle23aiContainer.getUsername()); + properties.setPassword(oracle23aiContainer.getPassword()); + return properties; } @Bean diff --git a/vector-stores/spring-ai-pgvector-store/src/test/java/org/springframework/ai/vectorstore/pgvector/PgVectorStoreCustomNamesIT.java b/vector-stores/spring-ai-pgvector-store/src/test/java/org/springframework/ai/vectorstore/pgvector/PgVectorStoreCustomNamesIT.java index e173763f39b..9d218a4b433 100644 --- a/vector-stores/spring-ai-pgvector-store/src/test/java/org/springframework/ai/vectorstore/pgvector/PgVectorStoreCustomNamesIT.java +++ b/vector-stores/spring-ai-pgvector-store/src/test/java/org/springframework/ai/vectorstore/pgvector/PgVectorStoreCustomNamesIT.java @@ -35,13 +35,11 @@ import org.springframework.beans.factory.annotation.Value; import org.springframework.boot.SpringBootConfiguration; import org.springframework.boot.autoconfigure.EnableAutoConfiguration; -import org.springframework.boot.context.properties.ConfigurationProperties; import org.springframework.boot.jdbc.autoconfigure.DataSourceAutoConfiguration; import org.springframework.boot.jdbc.autoconfigure.DataSourceProperties; import org.springframework.boot.test.context.runner.ApplicationContextRunner; import org.springframework.context.ApplicationContext; import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Primary; import org.springframework.jdbc.core.JdbcTemplate; import static org.assertj.core.api.Assertions.assertThat; @@ -49,6 +47,7 @@ /** * @author Muthukumaran Navaneethakrishnan * @author Thomas Vitale + * @author Eddú Meléndez */ @Testcontainers @EnabledIfEnvironmentVariable(named = "OPENAI_API_KEY", matches = ".+") @@ -63,11 +62,6 @@ public class PgVectorStoreCustomNamesIT { private final ApplicationContextRunner contextRunner = new ApplicationContextRunner() .withUserConfiguration(TestApplication.class) .withPropertyValues("test.spring.ai.vectorstore.pgvector.distanceType=COSINE_DISTANCE", - - // JdbcTemplate configuration - String.format("app.datasource.url=jdbc:postgresql://%s:%d/%s", postgresContainer.getHost(), - postgresContainer.getMappedPort(5432), "postgres"), - "app.datasource.username=postgres", "app.datasource.password=postgres", "app.datasource.type=com.zaxxer.hikari.HikariDataSource"); private static void dropTableByName(ApplicationContext context, String name) { @@ -232,10 +226,12 @@ public JdbcTemplate myJdbcTemplate(DataSource dataSource) { } @Bean - @Primary - @ConfigurationProperties("app.datasource") public DataSourceProperties dataSourceProperties() { - return new DataSourceProperties(); + DataSourceProperties properties = new DataSourceProperties(); + properties.setUrl(postgresContainer.getJdbcUrl()); + properties.setUsername(postgresContainer.getUsername()); + properties.setPassword(postgresContainer.getPassword()); + return properties; } @Bean diff --git a/vector-stores/spring-ai-pgvector-store/src/test/java/org/springframework/ai/vectorstore/pgvector/PgVectorStoreIT.java b/vector-stores/spring-ai-pgvector-store/src/test/java/org/springframework/ai/vectorstore/pgvector/PgVectorStoreIT.java index 77fce3f010b..51d11548840 100644 --- a/vector-stores/spring-ai-pgvector-store/src/test/java/org/springframework/ai/vectorstore/pgvector/PgVectorStoreIT.java +++ b/vector-stores/spring-ai-pgvector-store/src/test/java/org/springframework/ai/vectorstore/pgvector/PgVectorStoreIT.java @@ -56,13 +56,11 @@ import org.springframework.beans.factory.annotation.Value; import org.springframework.boot.SpringBootConfiguration; import org.springframework.boot.autoconfigure.EnableAutoConfiguration; -import org.springframework.boot.context.properties.ConfigurationProperties; import org.springframework.boot.jdbc.autoconfigure.DataSourceAutoConfiguration; import org.springframework.boot.jdbc.autoconfigure.DataSourceProperties; import org.springframework.boot.test.context.runner.ApplicationContextRunner; import org.springframework.context.ApplicationContext; import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Primary; import org.springframework.core.io.DefaultResourceLoader; import org.springframework.jdbc.core.JdbcTemplate; import org.springframework.util.CollectionUtils; @@ -76,6 +74,7 @@ * @author Thomas Vitale * @author Jihoon Kim * @author YeongMin Song + * @author Eddú Meléndez */ @Testcontainers @EnabledIfEnvironmentVariable(named = "OPENAI_API_KEY", matches = ".+") @@ -513,10 +512,12 @@ public JdbcTemplate myJdbcTemplate(DataSource dataSource) { } @Bean - @Primary - @ConfigurationProperties("app.datasource") public DataSourceProperties dataSourceProperties() { - return new DataSourceProperties(); + DataSourceProperties properties = new DataSourceProperties(); + properties.setUrl(postgresContainer.getJdbcUrl()); + properties.setUsername(postgresContainer.getUsername()); + properties.setPassword(postgresContainer.getPassword()); + return properties; } @Bean diff --git a/vector-stores/spring-ai-pgvector-store/src/test/java/org/springframework/ai/vectorstore/pgvector/PgVectorStoreObservationIT.java b/vector-stores/spring-ai-pgvector-store/src/test/java/org/springframework/ai/vectorstore/pgvector/PgVectorStoreObservationIT.java index d8c7e0be66b..11736787ec6 100644 --- a/vector-stores/spring-ai-pgvector-store/src/test/java/org/springframework/ai/vectorstore/pgvector/PgVectorStoreObservationIT.java +++ b/vector-stores/spring-ai-pgvector-store/src/test/java/org/springframework/ai/vectorstore/pgvector/PgVectorStoreObservationIT.java @@ -49,12 +49,10 @@ import org.springframework.ai.vectorstore.pgvector.PgVectorStore.PgIndexType; import org.springframework.boot.SpringBootConfiguration; import org.springframework.boot.autoconfigure.EnableAutoConfiguration; -import org.springframework.boot.context.properties.ConfigurationProperties; import org.springframework.boot.jdbc.autoconfigure.DataSourceAutoConfiguration; import org.springframework.boot.jdbc.autoconfigure.DataSourceProperties; import org.springframework.boot.test.context.runner.ApplicationContextRunner; import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Primary; import org.springframework.core.io.DefaultResourceLoader; import org.springframework.jdbc.core.JdbcTemplate; @@ -66,6 +64,7 @@ * * @author Christian Tzolov * @author Thomas Vitale + * @author Eddú Meléndez */ @EnabledIfEnvironmentVariable(named = "OPENAI_API_KEY", matches = ".+") @Testcontainers @@ -201,10 +200,12 @@ public JdbcTemplate myJdbcTemplate(DataSource dataSource) { } @Bean - @Primary - @ConfigurationProperties("app.datasource") public DataSourceProperties dataSourceProperties() { - return new DataSourceProperties(); + DataSourceProperties properties = new DataSourceProperties(); + properties.setUrl(postgresContainer.getJdbcUrl()); + properties.setUsername(postgresContainer.getUsername()); + properties.setPassword(postgresContainer.getPassword()); + return properties; } @Bean