How to combine Yeoman scaffolding with existing Java directory structure

后端 未结 1 475
無奈伤痛
無奈伤痛 2020-12-13 16:16

In my existing web project the directory structure for the served html content while development with jetty is \"myProject/src/main/webapp/\"

Now, I want to integrat

相关标签:
1条回答
  • 2020-12-13 17:07

    Take a look at my answer on how to do Django-Yeoman integration.
    Architectural concepts will be the same, even external articles (definitely must-reads) are Java-based.

    In short:

    • Use yeoman-maven-plugin. If you are on Gradle that's still ok. Even better, since you will have better control over which grunt tasks are being invoked.
    • Your project structure should resemble this:

      pom.xml
      
      src/
          main/
              java/
                  ...
              resources/
                  ...
              webapp/
                  WEB-INF/
      yo/
          dist/
          <<the rest of the Yeoman-generated stuff>>
      
    • Yeoman generators, including the one initialising the frontend part, should be invoked exclusively from yo directory.
    • The plugin takes care for copying production-ready yo/dist to WEB-INF.
      All you have to do is to serve the latter as a static resource.
      Config for Spring MVC (dispatcher servlet):

      <!--Yeoman static content-->
      <mvc:resources location="WEB-INF/yo/" mapping="/**"/>
      

      One should aim for similar config when using other technologies, like Jetty, or pure Servlet config.

    The rest, particularly dev setup, is described in referenced answer.

    0 讨论(0)
提交回复
热议问题