From c88e9ccbb2de4455a124812819cfafcee208f638 Mon Sep 17 00:00:00 2001 From: Benny Yen Date: Mon, 17 Jun 2024 17:00:07 +0800 Subject: [PATCH] docs: update README.md --- README.md | 6 ++--- vite-spring-webmvc/README.md | 49 +++++++++++++++++++++++++++++++++--- 2 files changed, 47 insertions(+), 8 deletions(-) diff --git a/README.md b/README.md index 419cbde..71a9ead 100644 --- a/README.md +++ b/README.md @@ -1,12 +1,10 @@ # JaVite -This monorepo contains various submodules for integrating Vite with different frameworks and -libraries. The primary focus is on modernizing legacy web applications by leveraging Vite's fast -build capabilities. +This monorepo contains various submodules for integrating Vite with different frameworks and libraries, focusing on modernizing legacy web applications with Vite's fast build capabilities. ## Project Structure -The monorepo is organized into the following submodules: +The monorepo includes the following submodules: - **vite-spring-webmvc**: Integrates Vite with JSP and Spring MVC applications. diff --git a/vite-spring-webmvc/README.md b/vite-spring-webmvc/README.md index fac8bb8..8ad7cd1 100644 --- a/vite-spring-webmvc/README.md +++ b/vite-spring-webmvc/README.md @@ -12,9 +12,11 @@ views, making it easier to modernize legacy web applications. ## Getting Started +If you need Java 8 support, please use [vite-spring-webmvc-jre8](https://github.com/benny123tw/javite/tree/main/vite-spring-webmvc-jre8). + ### Prerequisites -- Java 8 or higher +- Java 17 or higher - Spring MVC - Vite @@ -23,18 +25,27 @@ views, making it easier to modernize legacy web applications. Add the following dependency to your Maven `pom.xml` file: ```xml - io.github.benny123tw vite-spring-webmvc - 1.0.0 + 0.0.1 + + + + + io.github.benny123tw + vite-spring-webmvc-jre8 + 0.0.1 ``` Or for Gradle: ```groovy -implementation 'io.github.benny123tw:vite-spring-webmvc:1.0.0' +implementation 'io.github.benny123tw:vite-spring-webmvc:0.0.1' + +// Java 8 support +implementation 'io.github.benny123tw:vite-spring-webmvc-jre8:0.0.1' ``` ### Configuration @@ -95,6 +106,34 @@ public class WebConfig implements WebMvcConfigurer { } ``` +#### Enable Vite Configuration + +Configure your Spring application to enable Vite: + +```java +import io.github.benny123tw.servlet.annotation.EnableVite; + +@Configuration +@ComponentScan(basePackages = "com.benny", + includeFilters = @Filter(type = FilterType.ANNOTATION, value = Configuration.class)) +@EnableVite +public class AppConfig { + + @Bean + public static PropertySourcesPlaceholderConfigurer propertyConfigInDev() { + return new PropertySourcesPlaceholderConfigurer(); + } + + @Configuration + @Profile("dev") + @PropertySource("classpath:application-dev.properties") + static class DevConfig { + + } + +} +``` + #### Using the `ViteImport` Tag in JSP Add the taglib declaration to your JSP file and use the `vite:import` tag to include Vite assets: @@ -114,6 +153,8 @@ Add the taglib declaration to your JSP file and use the `vite:import` tag to inc ``` +Full example available on [benny123tw/vite-jsp-demo](https://github.com/benny123tw/vite-jsp-demo). + ## Contributing Contributions are welcome! Please feel free to submit a Pull Request.