我的 spring MVC 和 hibernate 应用程序有一个多 maven 模块。
我的布局如下:
/myapp-web
/myapp-web/src/main/java
/myapp-web/src/main/webapp
/myapp-web/src/main/webapp/web-inf
/myapp-web/src/main/webapp/web-inf/web.xml
/myapp-web/src/main/webapp/web-inf/web-context.xml (spring wiring code etc)
/myapp-web/src/main/webapp/web-inf/config/hibernate.cfg.xml
/myapp-web/src/main/webapp/assets/... (folder for css, javascript, images)
/myapp-web/src/main/webapp/views (folders with freemarker .ftl files)
我的 pom.xml:
..
<packaging>war</packaging>
..
<dependency>
<artifactId>jetty-server</artifactId>
<groupId>org.eclipse.jetty</groupId>
<version>${jetty-version}</version>
</dependency>
<dependency>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-servlet</artifactId>
<version>${jetty-version}</version>
</dependency>
<dependency>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-webapp</artifactId>
<version>${jetty-version}</version>
</dependency>
我有另一个嵌入式码头实例,我成功设置并且可以运行。我什至设置了一个启动/停止脚本,所以它可以在 Ubuntu 上运行。这不是一个 spring mvc 应用程序,所以它更容易,因为它没有 web.xml 文件等。 我创建了一个 /assembly/assembly.xml 文件,我是否也需要为 spring mvc 应用程序这样做?
然后我将此添加到我的 pom.xml 插件部分:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-assembly-plugin</artifactId>
<version>${maven-assembly-plugin}</version>
<configuration>
<descriptors>
<descriptor>src/main/assembly/assembly.xml</descriptor>
</descriptors>
</configuration>
</plugin>
<!-- jar plugin -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>${maven-jar-plugin}</version>
<configuration>
<archive>
</archive>
</configuration>
</plugin>
<!-- jetty plugin -->
<plugin>
<!-- This plugin is needed for the servlet example -->
<groupId>org.mortbay.jetty</groupId>
<artifactId>jetty-maven-plugin</artifactId>
<version>${jetty-version}</version>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<version>1.1</version>
<executions>
<execution>
<goals>
<goal>java</goal>
</goals>
</execution>
</executions>
<configuration>
<mainClass>com.myapp.HttpServer</mainClass>
</configuration>
</plugin>
我需要为我的 spring mvc 应用程序做同样的事情吗?
我在 stackoverflow 上发现了一些线程,但我无法理解 ant 部分,因为我没有使用 ant。我也不确定如何将其移植到 Maven 中:
令我惊讶的是,除了单个 servlet 示例之外,没有关于如何执行此操作的单一好的参考。
我需要为此创建一个 /assembly/assembly.xml 文件,还是为 Web 应用程序创建一个不同的文件?
有人可以逐步向我解释这个,以便我可以让它工作吗?请询问,我会发布我的项目所需的任何内容,但我认为我涵盖了我当前环境的所有内容,即:
- 使用多 Maven 设置
- 春天mvc
- 休眠
- 模板的freemarker
- 上面给出了文件夹结构
目标是能够部署这个war文件,创建启动/停止脚本,这样我就可以将它部署到我的服务器并启动/停止码头实例。