diff --git a/javite-webmvc-jre8/src/main/java/com/javite/spring/config/ViteConfig.java b/javite-webmvc-jre8/src/main/java/com/javite/spring/config/ViteConfig.java index c8ab81f..9401eb0 100644 --- a/javite-webmvc-jre8/src/main/java/com/javite/spring/config/ViteConfig.java +++ b/javite-webmvc-jre8/src/main/java/com/javite/spring/config/ViteConfig.java @@ -1,6 +1,6 @@ package com.javite.spring.config; -import org.springframework.boot.context.properties.EnableConfigurationProperties; +import org.springframework.beans.factory.annotation.Value; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; @@ -30,9 +30,20 @@ * @see com.javite.spring.annotation.EnableVite */ @Configuration -@EnableConfigurationProperties(ViteProperties.class) public class ViteConfig { + @Value("${vite.debug:true}") + private boolean debug; + + @Value("${vite.manifestPath:/WEB-INF/dist/.vite/manifest.json}") + private String manifestPath; + + @Value("${vite.localServerUrl:http://localhost:5173}") + private String localServerUrl; + + @Value("${vite.resourcePath:/resources}") + private String resourcePath; + /** * Creates a {@link ViteProperties} bean configured with the application's Vite settings. * @@ -40,7 +51,12 @@ public class ViteConfig { */ @Bean public ViteProperties viteProperties() { - return new ViteProperties(); + ViteProperties viteProperties = new ViteProperties(); + viteProperties.setDebug(debug); + viteProperties.setManifestPath(manifestPath); + viteProperties.setLocalServerUrl(localServerUrl); + viteProperties.setResourcePath(resourcePath); + return viteProperties; } } diff --git a/javite-webmvc/src/main/java/com/javite/spring/config/ViteConfig.java b/javite-webmvc/src/main/java/com/javite/spring/config/ViteConfig.java index c8ab81f..49b5f74 100644 --- a/javite-webmvc/src/main/java/com/javite/spring/config/ViteConfig.java +++ b/javite-webmvc/src/main/java/com/javite/spring/config/ViteConfig.java @@ -1,38 +1,30 @@ package com.javite.spring.config; -import org.springframework.boot.context.properties.EnableConfigurationProperties; +import org.springframework.beans.factory.annotation.Value; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; /** - * Provides an out-of-the-box configuration for integrating Vite with Spring MVC applications. + * Configuration class for integrating Vite with Spring MVC applications. * - *
This configuration class automatically scans the package {@code io.github.benny123tw.servlet.config} - * for components and provides the necessary beans and properties to enable Vite integration.
- * - *The following properties can be configured in the application's {@code application.properties} file:
- *Usage example:
- *- * @Configuration - * @EnableVite - * public class AppConfig { - * // Your other Spring configuration - * } - *- * - * @see com.javite.spring.annotation.EnableVite + *
This class defines beans for Vite properties that can be customized through the application's + * {@code application.properties} file.
*/ @Configuration -@EnableConfigurationProperties(ViteProperties.class) public class ViteConfig { + @Value("${vite.debug:true}") + private boolean debug; + + @Value("${vite.manifestPath:/WEB-INF/dist/.vite/manifest.json}") + private String manifestPath; + + @Value("${vite.localServerUrl:http://localhost:5173}") + private String localServerUrl; + + @Value("${vite.resourcePath:/resources}") + private String resourcePath; + /** * Creates a {@link ViteProperties} bean configured with the application's Vite settings. * @@ -40,7 +32,11 @@ public class ViteConfig { */ @Bean public ViteProperties viteProperties() { - return new ViteProperties(); + ViteProperties viteProperties = new ViteProperties(); + viteProperties.setDebug(debug); + viteProperties.setManifestPath(manifestPath); + viteProperties.setLocalServerUrl(localServerUrl); + viteProperties.setResourcePath(resourcePath); + return viteProperties; } - }