Maven模块用于静态文件 [英] Maven module for static files

查看:152
本文介绍了Maven模块用于静态文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个有spring和maven的web应用程序。应用程序分为maven模块。我有一个应用程序网络模块,产生战争。另一个产生耳朵的应用耳模块。另一个应用程序静态,带有生成zip文件的css,js和图像。



这将是我的应用程序的大纲:




  • 应用程序


    • 应用程序网络(java代码)

    • 应用程序

    • application-static(css,js and images)

    • 应用程序资源(语言属性)




我想部署eclipse使用static模块的文件,而不是使用application / src / main / webapp目录。我该怎么做?这是可能的?

解决方案

不要浪费你的时间开箱资源,一切都可以开箱即用:


  1. 资源束:始终从类路径加载,无论是分解( WEB-INF / classes )或压缩( WEB-INF / lib

  2. 提供静态资源:将其捆绑在JAR中,并使用Tomcat (Servlet 3.0)功能从 META-INF / resources 提供,请参阅此处或使用Spring的内置 mvc:resources 元素。

只需将相关性片段添加到WAR POM中即可完成。


I have a web application with spring and maven. The application is divided into maven modules. I have an "application-web" module that generates war. Another "application-ear" module that generates an ear. And another "application-static" with css, js and images that generates a zip file.

This would be the outline of my application:

  • application
    • application-web (java code)
    • application-ear
    • application-static (css, js and images)
    • application-resources (language properties)

I want to deploy the eclipse use files of "static" module, instead of using the files in the "application/src/main/webapp" directory. How can I do this? It is possible?

解决方案

Don't waste your time with unpacking resources, everything works out of the box:

  1. Resource bundles: the are always loaded from the classpath, regardlessly it is exploded (WEB-INF/classes) or compressed (WEB-INF/lib)
  2. Serving static resources: bundle them up in a JAR and use either Tomcat (Servlet 3.0) feature to serve from META-INF/resources, see here or use Spring's built in mvc:resources element.

Simply add the dependency snippets in your WAR POM and your are done.

这篇关于Maven模块用于静态文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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