如何将 Yeoman 脚手架与现有的 Java 目录结构结合起来 [英] How to combine Yeoman scaffolding with existing Java directory structure

查看:24
本文介绍了如何将 Yeoman 脚手架与现有的 Java 目录结构结合起来的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我现有的 web 项目中,使用 jetty 进行开发时提供的 html 内容的目录结构是myProject/src/main/webapp/"

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

现在,我想在这里集成一个 angularjs 项目.我和 Yeoman 玩了一会儿.

Now, I want to integrate an angularjs project here. I've played a little bit with Yeoman.

如果我使用 yeoman 搭建脚手架,我想知道如何将其集成到我们现有的开发和部署结构中.我想使用主文件夹myProject"来运行自耕农脚手架就可以了.然后我会为我的所有前端内容获得一个myProject/app/"目录.我应该以某种方式(如何?)指示我的码头服务器使用.../src/main/webapp/"作为新应用程序目录的别名?

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?

我们主要使用jetty作为请求后端的代理.有没有办法结合jetty进行类似于yeoman server"的实时重载?

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?

推荐答案

看一看 我对如何做 Django-Yeoman 的回答整合.
架构概念将是相同的,即使是外部文章(绝对必读)也是基于 Java 的.

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.

简而言之:

  • 使用 yeoman-maven-plugin.如果你在 Gradle 上,那还是可以的.更好的是,因为您可以更好地控制调用哪些 grunt 任务.
  • 您的项目结构应类似于:

  • 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 生成器,包括初始化前端部分的生成器,应专门从 yo 目录中调用.
  • 该插件负责将生产就绪的 yo/dist 复制到 WEB-INF.
    您所要做的就是将后者作为静态资源提供服务.
    Spring MVC(调度程序 servlet)的配置:

  • 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="/**"/>
    

    在使用其他技术(如 Jetty 或纯 Servlet 配置)时,应针对类似的配置.

    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.

    这篇关于如何将 Yeoman 脚手架与现有的 Java 目录结构结合起来的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

  • 查看全文
    登录 关闭
    扫码关注1秒登录
    发送“验证码”获取 | 15天全站免登陆