我有一个用于我的spring MVC和hibernate应用程序的多重maven模块。嵌入式跳台MVC
我的布局如下:
/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上发现了几个threads,但我不明白蚂蚁的一部分,因为我没有使用ant。我也不知道如何移植到maven的工作:
我很惊讶,没有一个单一的良好参考如何做到这一点,而不是单个servlet的例子。
是否需要为此创建/assembly/assembly.xml文件,或者针对Web应用程序,情况有所不同?
有人可以解释这一步一步一步,所以我可以得到这个工作? 请让我将张贴必要的东西为我的项目,但我想我涵盖了所有我现在的环境了,即:
- 使用多行家设置
- Spring MVC的
- 冬眠
- 为模板的freemarker
- 文件夹结构上面
给出的目标是能够部署这个娃r文件,创建启动/停止脚本,以便我可以将其部署到我的服务器并启动/停止jetty实例。
如果你坚持标准的maven项目布局(你似乎做了什么),maven jetty:run命令将从相应的路径中选择你的web应用程序,而不是加载.war。在我使用的简单项目中,不需要额外的配置,足以进行测试和开发。如果你需要部署生产。战争,看看[货物插件](http://cargo.codehaus.org/Maven2+plugin)? – Pyranja
我不想在本地使用mvn jetty运行码头:运行命令,这是为了部署。 – Blankman