从仅包含HTML,CSS&的网络应用生成.war文件的JavaScript [英] Generate .war file from web app containing just HTML, CSS & JavaScript
问题描述
我正在尝试创建一个将在Web /应用程序服务器上部署的war文件。
I am trying to create a war file that will be deployed on a web/application server.
应用程序的源文件完全是HTML,CSS和JavaScript。对于我们的REST API和我们的其余后端代码,有一个单独的war文件。
The source files of the app are purely HTML, CSS, and JavaScript. There is a separate war file for our REST API and for the rest of our backend code.
那里的大多数指南都谈到使用Java进行编译,并指向WEB-INF文件夹等。
Most of the guides out there talk about using java to compile, and pointing to WEB-INF folders etc.
但是,正如我提到的,在HTML / CSS / JS战争中,我不使用任何Java,也不使用WEB-INF,并且通常没有在 Java中看到的servlet或其他内容。战争文件。
However, as I mentioned, in the HTML/CSS/JS war, I don't use any Java, don't use WEB-INF, and there are no servlets or other things you would normally see in a "Java" war file.
我如何编译或创建这种类型的战争文件?
How do I compile or create this type of war file?
内容如下:
WebContent / HTML
WebContent / CSS
WebContent / JS
WebContent/HTML WebContent/CSS WebContent/JS
包含JavaScript的所有库在JS文件夹中。
All libraries for JavaScript contained within JS folder.
这项工作是否可行:只需运行:
Would this work: Simply run:
src.dist="./WebContent"
app.name="example"
app.version=1
work.home="./temp"
jar jarfile="${src.dist}/${app.name}-${app.version}.war"
basedir="${work.home}"
很明显,我会正确设置脚本的其余部分。
Obviously I would have set up the rest of the script correctly.
推荐答案
这非常简单:
- 创建文件夹
- 添加
src / main / webapp
文件夹 - 添加所有将HTML,CSS和JS文件保存到
src / main / webapp
文件夹 - 添加一个空的 web.xml 文件添加到
src / main / webapp / WEB-INF
目录。 - 添加一个maven pom.xml
-
使用以下配置将maven-war-plugin添加到pom.xml:
- Create a folder
- Add a
src/main/webapp
folder - Add all of your HTML, CSS and JS files to the
src/main/webapp
folder - Add an empty web.xml file to the
src/main/webapp/WEB-INF
directory. - add a maven pom.xml
add the maven-war-plugin to your pom.xml, with the following configuration:
<!-- create the war -->
<plugin>
<artifactId>maven-war-plugin</artifactId>
<configuration>
<webXml>src/main/webapp/WEB-INF/web.xml</webXml>
</configuration>
</plugin>
运行mvn全新安装!
run mvn clean install!
这篇关于从仅包含HTML,CSS&的网络应用生成.war文件的JavaScript的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!