Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version
  1. Create a new Spring Boot application or open your existing Spring Boot project.

  2. Add the petite-vue dependencies to your Spring Boot application. You can do this by adding the following dependency to your pom.xml file:

<dependency>
    <groupId>dev.petite</groupId>
    <artifactId>petite-vue</artifactId>
    <version>1.1.0</version>
</dependency>
  1. Create a new controller in your Spring Boot application to serve your petite-vue files. You can create a new class with an @RestController annotation and configure a @RequestMapping to serve your petite-vue files as static resources.
@RestController
public class PetiteVueController {

    @RequestMapping("/")
    public String index() {
        return "index.html";
    }

    @RequestMapping("/**")
    public Resource fallbackIndex(@RequestBody byte[] body, HttpServletRequest request) {
        return new ClassPathResource("static/" + request.getRequestURI());
    }

}

In this example, we use the @RequestMapping("/") annotation to serve the index.html file as the default page of our petite-vue application, and we use the @RequestMapping("/**") annotation to serve all other requests for static resources.

  1. Create a static directory in your Spring Boot project and place all your petite-vue files in it. By default, Spring Boot will automatically serve files from this directory as static resources, so there's no need for any additional configuration.

  2. Run your Spring Boot application and navigate to the URL where your application is hosted. You should now see your petite-vue frontend rendered and displayed correctly.

If your petite-vue application requires API calls to your Spring Boot backend, you can use the axios library to make HTTP requests to your backend API endpoints. You can import axios directly into your petite-vue components using a script tag, or you can use a module bundler like webpack to manage your dependencies.