`

Spring_mvn_build_install_run

 
阅读更多

#1 download spring  version(2.0.8 or other)   ==> for aip local

        spring-framework-2.0.8-with-dependencies.zip

 

#2 mvn pom.xml   ==> load jar for server

   blog:  Getting started with maven and spring

   add dependence:

   <dependency>

      <groupId>org.springframework</groupId>
      <artifactId>spring</artifactId>
      <version>2.0.8</version>
 </dependency>
 

 

#3 config web.xml ==> install spring

  step one:

     add file:applicationContext.xml

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN 2.0//EN" "http://www.springframework.org/dtd/spring-beans-2.0.dtd">

<beans>
  <bean id="messageStore" class="com.mark.core.struts2.model.MessageStore">
    <property name="message" value="MessageStore test" />
  </bean>
</beans>
 

  step two:

     config web.xml

<listener>
		<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
 

 

#4 test first application

   package com.mark.core.spring2_0_8;

import org.springframework.context.ApplicationContext;
import org.springframework.context.support.FileSystemXmlApplicationContext;

import com.mark.core.struts2.model.MessageStore;

public class Test {
	public static void main(String[] args) {
		ApplicationContext ac = new FileSystemXmlApplicationContext("src\\main\\webapp\\WEB-INF\\applicationContext.xml");
		MessageStore m = (MessageStore)ac.getBean("messageStore");
		System.out.println(m.getMessage());
	}
}
 

 

#5 note

分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics