Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
754 views
in Technique[技术] by (71.8m points)

angularjs - How to combine Yeoman scaffolding with existing Java directory structure

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 integrate an angularjs project here. I've played a little bit with Yeoman.

If I'm scaffolding with yeoman, I'm wondering how I can integrate it into our existing dev and deployment structure. I suppose to use the main folder "myProject" to run yeoman scaffolding would be fine. Then I would get a "myProject/app/" diretory for all my frontend stuff. Should I instruct somehow (how?) my jetty server to use ".../src/main/webapp/" as an alias for the new app directory?

We use jetty mainly as a proxy for requesting the backend. Is there also a way to do a live reload similar to "yeoman server" in combination with jetty?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...