I have a multiple maven module for my spring MVC and hibernate application.
My layout is as follows:
/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)
My 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>
I have another instance of embedded jetty that I successfully setup and I can run. I even setup a start/stop script so it works on Ubuntu. This wasn't a spring mvc application so it was a easier since it doesn't have a web.xml file etc. I created an /assembly/assembly.xml file, do I need to do that for a spring mvc application also?
I then added this to my pom.xml plugins section:
<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>
Do I need to do the same for my spring mvc application?
I found a few threads on stackoverflow, but I can't understand the ant part as I am not using ant. I am also not sure how to port it to work with maven:
I'm surprised that there isn't a single good reference on how to do this, other than for single servlet example.
Do I need to create a /assembly/assembly.xml file for this, or for a web application things are different?
Can someone explain this to me step by step so I can get this to work? Please ask and I will post anything necessary for my project, but I think I covered all that my current environment has, i.e.:
- using a multi maven setup
- spring mvc
- hibernate
- freemarker for templates
- folder structure is given above
The goal is to be able to deploy this war file, create the startup/stop scripts so I can deploy this to my server and start/stop the jetty instance.