One: Create Maven's WebApp project Ppweb
Pom.xml content is as follows:
<project xmlns= "http://maven.apache.org/POM/4.0.0" xmlns:xsi= "Http://www.w3.org/2001/XMLSchema-instance" xsi: schemalocation= "http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd" ><modelversion >4.0.0</modelversion><groupid>com.lala</groupid><artifactid>ppweb</artifactid ><packaging>war</packaging><version>1.0.0</version><name>ppweb Maven Webapp< /name><url>http://maven.apache.org</url><dependencies><dependency><groupid> Junit</groupid><artifactid>junit</artifactid><version>4.12</version><scope >test</scope></dependency><dependency><groupId>javax.servlet</groupId>< Artifactid>jsp-api</artifactid><version>2.0</version><scope>provided</scope> </dependency><dependency><groupid>javax.servlet</groupid><artifactid>servlet-api </artifactid><version>2.5</version><scope>provided</scope></dependency></dependencies> <build><finalName>ppweb</finalName><plugins><plugin><groupId> Org.apache.maven.plugins</groupid><artifactid>maven-compiler-plugin</artifactid><version >3.3</version><configuration><source>1.7</source><target>1.7</target> </configuration></plugin><plugin> <groupid>org.apache.tomcat.maven</groupid> ; <artifactId>tomcat7-maven-plugin</artifactId> <version>2.2</version> <configuration> <path>/</path> <port>9090</port& Gt <uriEncoding>UTF-8</uriEncoding> </configuration> </plugin><plugi N><groupid>org.apache.maven.plugins</groupId><artifactId>maven-war-plugin</artifactId><version>2.6</version>< configuration><archive><manifest><addclasspath>false</addclasspath>< classpathprefix>web-inf/lib/</classpathprefix></manifest><manifestentries>< bundle-manifestversion>2</bundle-manifestversion><class-path>${project.build.finalname}.jar< /class-path><bundle-name>${project.groupid}.${project. Artifactid}</bundle-name><bundle-symbolicname>${project.groupid}.${project. artifactid}</bundle-symbolicname><bundle-version>${project.version}</bundle-version>< Bundle-vendor>${project.groupid}</bundle-vendor><import-package>org.osgi.framework, javax.servlet.http,javax.servlet</import-package><embed-dependency>*</embed-dependency>< Dynamicimport-package>*</dynamicimport-package><web-contextpath>/ppweb</web-contextpath> <bundle-claSspath>.,web-inf/classes</bundle-classpath></manifestentries></archive></configuration ></plugin></plugins></build></project>
Note: Here's the Tomcat7-maven-plugin plugin, optional, here is for the convenience of running locally (MVN tomcat7:run)
Two:
Edit the src/main/java/webapp/index.jsp file to add some content
Three:
Download Apache-servicemix, and unzip
Four:
Packaging the above Web project, MVN package
Throw the resulting war into the Apache-servicemix's deploy directory
Finally, start Apache-servicemix, execute Bin/servicemix.bat
In the pop-up window, enter list to see the bundle lists
See, the Ppweb project here has been successfully installed.
Open the browser, enter Http://127.0.0.1:8181/ppweb, you can access
Note that the Web port defaults to 8181
Here the/ppweb, is the configuration of the above Web-contextpath, need to remain consistent
Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.
Developing OSGi Web examples using Maven,apache servicemix