OSGi-based Virgo server's simplest spring Web instance __osgi

Source: Internet
Author: User

Virgo server's simplest spring Web instance based on OSGi

One: the development tool downloads and the environment constructs

1. Download and install the jdk6u30 version, download the following address:

Http://www.oracle.com/technetwork/java/javasebusiness/downloads/java-archive-downlo

Ads-javase6-419409.html#jdk-6u30-oth-jpr

2. Download and install the Springsourcetools Suite Development IDE Tools version 2.7.2.RELEASE, download the address:

http://download.springsource.com/release/sts/2.7.2/dist/e3.7/springsource-tool-suite-

2.7.2.release-e3.7-win32-installer.exe

3. Download and install Virgoserver version 3.0.2, download the address is:

Http://www.eclipse.org/downloads/download.php?file=/virgo/release/VTS/3.0.2.RE

Lease/virgo-tomcat-server-3.0.2.release.zip

4. Download and install the MAVEN tools version 3.03, download the address:

Http://www.apache.org/dyn/closer.cgi/maven/binaries/apache-maven-3.0.3-bin.zip.

5. Open the installed STS (SpringSource tools Suite) tool, Menu > Help > Install New

Software > http://subclipse.tigris.org/update_1.6.x update installation virgo server plugin

Two: Create Webbundle project

Virgoserver and Maven are extracted separately to D:\osgi\project\virgo_tomcat and D:\osgi\project\maven

1. Open sts (Springsourcetools Suite), select Menu->window->preferences->maven->

Installations


2. Create a Mavenbundle project based on wizard and choose WebApp to be a Web bundle item at the time of choice:


Right-click to create a good project and select Springtools-> enable OSGi in the pop-up menu

Then select Springtools-> Enable incremental generation of MANIFEST again. MF file

3. Start and access the Virgoserver splash page

Right-click in ServerView to select New->server, pop up the following screen:

Select Virgoweb Server after clicking the "Add" button

Click "Finish" to end the configuration, click on the Start button in ServerView, start virgoserver after

In the browser input http://localhost:8080 can see the following screen

4. The project layout is as follows:


5. Web.xml Content

<! DOCTYPE Web-app Public "-//sun Microsystems, INC.//DTD Web Application 2.3//en" "Http://java.sun.com/dtd/web-app_2_3.dt D "> <web-app> <display-name>archetype Created Web application</display-name> <context-param&
		Gt
			<param-name>contextClass</param-name> <param-value>
	Org.eclipse.virgo.web.dm.ServerOsgiBundleXmlWebApplicationContext </param-value> </context-param> <listener> <listener-class> Org.springframework.web.context.ContextLoaderListener </listener-class
			> </listener> <servlet> <servlet-name>gloomyfish</servlet-name> <servlet-class> Org.springframework.web.servlet.DispatcherServlet </servlet-class> <load-on-startup>1</ load-on-startup> </servlet> <servlet-mapping> <servlet-name>gloomyfish</servlet-name> & Lt;url-pattern>/app/*</url-pattern> </servlet-mapping> <welcome-file-list> <welcome-file>Hello.jsp</welcome-file> </welcome-file-list> </web-app>
 
6. Gloomyfish-servlet.xml Content

<?xml version= "1.0" encoding= "UTF-8"?> <beans "xmlns=" xmlns:
Xsi= "Http://www.w3.org/2001/XMLSchema-instance" xmlns:context= "Http://www.springframework.org/schema/context" Xmlns:mvc= "Http://www.springframework.org/schema/mvc" xsi:schemalocation= "Http://www.springframework.org/schema
/MVC http://www.springframework.org/schema/mvc/spring-mvc-3.0.xsd Http://www.springframework.org/schema/beans Http://www.springframework.org/schema/beans/spring-beans.xsd Http://www.springframework.org/schema/context http ://www.springframework.org/schema/context/spring-context.xsd "> <context:component-scan base-package=" Com.gloomyfish.web "/> <!--enable Anntotation-driven controllers--> <bean class=" Org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter "/> <!--Configure Freemarker Support--> <bean id= "Freemarkerconfig" class= "
Org.springframework.web.servlet.view.freemarker.FreeMarkerConfigurer ">	<property name= "Templateloaderpath" value= "/web-inf/ftl/"/> </bean> <bean id= "Viewresolver" class= " Org.springframework.web.servlet.view.freemarker.FreeMarkerViewResolver "> <property name=" Cache "Value=" true "/> <property name=" suffix "value=". Ftl "/> </bean> </beans>

Package deployment project, after using MAVEN compilation package, select the configured Virgo server icon, right-click [Add and Remove]

Select the item in the pop-up dialog box, click Add to add to Virgo server click Finish


Start the run, select the green run icon, start Virgo sever access the following URL:

Http://localhost:8080/gloomyfish, see effect is a HTML5 based on the Taiji case, the request in support of HTML5

The browser can see the effect as follows:
Project Packaging Source code download address is:

http://download.csdn.net/detail/jia20003/4375418


Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.