spring 框架使用初步
2009-12-30 14:40:55 来源:WEB开发网核心提示:由于刚刚开始学习sPRing,对于他的理解也不是非常的透彻,spring 框架使用初步,从我个人的角度来说,能够使用他进行mvc开发就已经足够了,spring要运行必须需要两个jar文件spring.jar(dist目录下面)commons-logging.jar(lib\jakarta-commons目录下面) 4、
由于刚刚开始学习sPRing,对于他的理解也不是非常的透彻,从我个人的角度来说,能够使用他进行mvc开发就已经足够了。
目标:能够把spring框架集成到开发环境中。
工具:eclipse + spring2.5.6
步骤:1、下载eclipse 或者是myeclipse 根据个人喜好从网上下载。
2、下载spring2.5.6(目前最高版本是3.0) 到spring官方网站下载 http://www.springsource.org/download 。注意:下载前
需要填写个人资料。要下载spring-framework-2.5.6-with-dependencies版本
3、解压spring。spring要运行必须需要两个jar文件
spring.jar(dist目录下面)
commons-logging.jar(lib\jakarta-commons目录下面)
4、接下来就是使用eclipse建立一个工程(java 或者 web工程都可以)
5、把上面的两个jar文件添加进入工程中。
6、测试是否集成成功
view plaincopy to clipboardprint?
package my.sh.spring;
import org.springframework.context.applicationContext;
import org.springframework.context.support.ClassPathxmlApplicationContext;
public class springtest {
public static void main(String[] args) {
ApplicationContext ctx = new ClassPathXmlApplicationContext("applicationContext.xml");
}
}
package my.sh.spring;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;
public class springtest {
public static void main(String[] args) {
ApplicationContext ctx = new ClassPathXmlApplicationContext("applicationContext.xml");
}
}
观察控制台输出
正确输出:
view plaincopy to clipboardprint?
2009-12-30 9:03:28 org.springframework.context.support.AbstractApplicationContext prepareRefresh
信息: Refreshing org.springframework.context.support.ClassPathXmlApplicationContext@ecd7e: display name [org.springframework.context.support.ClassPathXmlApplicationContext@ecd7e]; startup date [Wed Dec 30 09:03:28 CST 2009]; root of context hierarchy
2009-12-30 9:03:28 org.springframework.beans.factory.xml.XmlBeanDefinitionReader loadBeanDefinitions
信息: Loading XML bean definitions from class path resource [applicationContext.xml]
2009-12-30 9:03:28 org.springframework.context.support.AbstractApplicationContext obtainFreshBeanFactory
信息: Bean factory for application context [org.springframework.context.support.ClassPathXmlApplicationContext@ecd7e]: org.springframework.beans.factory.support.DefaultListableBeanFactory@60e128
2009-12-30 9:03:28 org.springframework.beans.factory.support.DefaultListableBeanFactory preInstantiateSingletons
信息: Pre-instantiating singletons in org.springframework.beans.factory.support.DefaultListableBeanFactory@60e128: defining beans []; root of factory hierarchy
2009-12-30 9:03:28 org.springframework.context.support.AbstractApplicationContext prepareRefresh
信息: Refreshing org.springframework.context.support.ClassPathXmlApplicationContext@ecd7e: display name [org.springframework.context.support.ClassPathXmlApplicationContext@ecd7e]; startup date [Wed Dec 30 09:03:28 CST 2009]; root of context hierarchy
2009-12-30 9:03:28 org.springframework.beans.factory.xml.XmlBeanDefinitionReader loadBeanDefinitions
信息: Loading XML bean definitions from class path resource [applicationContext.xml]
2009-12-30 9:03:28 org.springframework.context.support.AbstractApplicationContext obtainFreshBeanFactory
信息: Bean factory for application context [org.springframework.context.support.ClassPathXmlApplicationContext@ecd7e]: org.springframework.beans.factory.support.DefaultListableBeanFactory@60e128
2009-12-30 9:03:28 org.springframework.beans.factory.support.DefaultListableBeanFactory preInstantiateSingletons
信息: Pre-instantiating singletons in org.springframework.beans.factory.support.DefaultListableBeanFactory@60e128: defining beans []; root of factory hierarchy
如果你没有引用 commons-logging.jar ,会输出如下错误提示
view plaincopy to clipboardprint?
Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/commons/logging/LogFactory
at org.springframework.context.support.AbstractApplicationContext.<init>(AbstractApplicationContext.java:145)
at org.springframework.context.support.AbstractRefreshableApplicationContext.<init>(AbstractRefreshableApplicationContext.java:84)
at org.springframework.context.support.AbstractRefreshableConfigApplicationContext.<init>(AbstractRefreshableConfigApplicationContext.java:59)
at org.springframework.context.support.AbstractXmlApplicationContext.<init>(AbstractXmlApplicationContext.java:58)
at org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:136)
at org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:83)
at my.sh.spring.springtest.main(springtest.java:9)
本文来自CSDN博客,转载请标明出处:http://blog.csdn.net/msjqd/archive/2009/12/30/5103718.aspx
目标:能够把spring框架集成到开发环境中。
工具:eclipse + spring2.5.6
步骤:1、下载eclipse 或者是myeclipse 根据个人喜好从网上下载。
2、下载spring2.5.6(目前最高版本是3.0) 到spring官方网站下载 http://www.springsource.org/download 。注意:下载前
需要填写个人资料。要下载spring-framework-2.5.6-with-dependencies版本
3、解压spring。spring要运行必须需要两个jar文件
spring.jar(dist目录下面)
commons-logging.jar(lib\jakarta-commons目录下面)
4、接下来就是使用eclipse建立一个工程(java 或者 web工程都可以)
5、把上面的两个jar文件添加进入工程中。
6、测试是否集成成功
view plaincopy to clipboardprint?
package my.sh.spring;
import org.springframework.context.applicationContext;
import org.springframework.context.support.ClassPathxmlApplicationContext;
public class springtest {
public static void main(String[] args) {
ApplicationContext ctx = new ClassPathXmlApplicationContext("applicationContext.xml");
}
}
package my.sh.spring;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;
public class springtest {
public static void main(String[] args) {
ApplicationContext ctx = new ClassPathXmlApplicationContext("applicationContext.xml");
}
}
观察控制台输出
正确输出:
view plaincopy to clipboardprint?
2009-12-30 9:03:28 org.springframework.context.support.AbstractApplicationContext prepareRefresh
信息: Refreshing org.springframework.context.support.ClassPathXmlApplicationContext@ecd7e: display name [org.springframework.context.support.ClassPathXmlApplicationContext@ecd7e]; startup date [Wed Dec 30 09:03:28 CST 2009]; root of context hierarchy
2009-12-30 9:03:28 org.springframework.beans.factory.xml.XmlBeanDefinitionReader loadBeanDefinitions
信息: Loading XML bean definitions from class path resource [applicationContext.xml]
2009-12-30 9:03:28 org.springframework.context.support.AbstractApplicationContext obtainFreshBeanFactory
信息: Bean factory for application context [org.springframework.context.support.ClassPathXmlApplicationContext@ecd7e]: org.springframework.beans.factory.support.DefaultListableBeanFactory@60e128
2009-12-30 9:03:28 org.springframework.beans.factory.support.DefaultListableBeanFactory preInstantiateSingletons
信息: Pre-instantiating singletons in org.springframework.beans.factory.support.DefaultListableBeanFactory@60e128: defining beans []; root of factory hierarchy
2009-12-30 9:03:28 org.springframework.context.support.AbstractApplicationContext prepareRefresh
信息: Refreshing org.springframework.context.support.ClassPathXmlApplicationContext@ecd7e: display name [org.springframework.context.support.ClassPathXmlApplicationContext@ecd7e]; startup date [Wed Dec 30 09:03:28 CST 2009]; root of context hierarchy
2009-12-30 9:03:28 org.springframework.beans.factory.xml.XmlBeanDefinitionReader loadBeanDefinitions
信息: Loading XML bean definitions from class path resource [applicationContext.xml]
2009-12-30 9:03:28 org.springframework.context.support.AbstractApplicationContext obtainFreshBeanFactory
信息: Bean factory for application context [org.springframework.context.support.ClassPathXmlApplicationContext@ecd7e]: org.springframework.beans.factory.support.DefaultListableBeanFactory@60e128
2009-12-30 9:03:28 org.springframework.beans.factory.support.DefaultListableBeanFactory preInstantiateSingletons
信息: Pre-instantiating singletons in org.springframework.beans.factory.support.DefaultListableBeanFactory@60e128: defining beans []; root of factory hierarchy
如果你没有引用 commons-logging.jar ,会输出如下错误提示
view plaincopy to clipboardprint?
Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/commons/logging/LogFactory
at org.springframework.context.support.AbstractApplicationContext.<init>(AbstractApplicationContext.java:145)
at org.springframework.context.support.AbstractRefreshableApplicationContext.<init>(AbstractRefreshableApplicationContext.java:84)
at org.springframework.context.support.AbstractRefreshableConfigApplicationContext.<init>(AbstractRefreshableConfigApplicationContext.java:59)
at org.springframework.context.support.AbstractXmlApplicationContext.<init>(AbstractXmlApplicationContext.java:58)
at org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:136)
at org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:83)
at my.sh.spring.springtest.main(springtest.java:9)
本文来自CSDN博客,转载请标明出处:http://blog.csdn.net/msjqd/archive/2009/12/30/5103718.aspx
[]
- ››使用脚本恢复WinXP系统的用户登录密码
- ››使用phpMyadmin创建数据库及独立数据库帐号
- ››使用Zend Framework框架中的Zend_Mail模块发送邮件...
- ››使用cout标准输出如何控制小数点后位数
- ››使用nofollow标签做SEO的技巧
- ››使用 WebSphere Message Broker 的 WebSphere Tra...
- ››使用SQL Server事件探查器做应用程序的性能分析
- ››使用SQL Server事件探查器分析死锁原因
- ››使用纯文本文件打造WCF服务
- ››使用 Dojo 开发定制 Business Space 小部件,第 4...
- ››使用 ADDRESS 与 INDIRECT函数查询信息
- ››使用 COLUMN函数编制单元信息
更多精彩
赞助商链接