Storing web content in a JAR file

后端 未结 6 1691
被撕碎了的回忆
被撕碎了的回忆 2021-02-14 03:16

Is it possible to store web content (such as JSPs, HTML, images, CSS etc) in a JAR file?

I\'ve been looking at various options at modularising our web applications and t

6条回答
  •  独厮守ぢ
    2021-02-14 03:29

    If you are using Maven to build your webapp, you can build a WAR of your resources and overlay that WAR onto your webapp WAR at build time.

    The resource WAR containing all of your JSPs, images, CSS, etc. is referred to as an "overlay," and is simply a dependency in your target webapp with the type set to "war."

    When you package your webapp, the resource WAR will only copy over non-conflicting files. So, if you have a unique index.jsp in your project, and would like to use that instead of the index.jsp in the overlay, just include it in your target webapp, and Maven will not copy over that resource.

    More info on the Maven War plugin page about overlays.

提交回复
热议问题