发布于 2017-09-07 10:04:52 | 173 次阅读 | 评论: 0 | 来源: 网友投递

这里有新鲜出炉的精品教程,程序狗速度看过来!

Spring Framework 开源j2ee框架

Spring是什么呢?首先它是一个开源的项目,而且目前非常活跃;它是一个基于IOC和AOP的构架多层j2ee系统的框架,但它不强迫你必须在每一层 中必须使用Spring,因为它模块化的很好,允许你根据自己的需要选择使用它的某一个模块;它实现了很优雅的MVC,对不同的数据访问技术提供了统一的接口,采用IOC使得可以很容易的实现bean的装配,提供了简洁的AOP并据此实现Transcation Managment,等等


下面小编就为大家带来一篇maven搭建spring项目(图文教程)。小编觉得挺不错的,现在就分享给大家,也给大家做个参考。一起跟随小编过来看看吧

开发工具:MyEclipse2014版(jdk1.7)+Maven3.9。

新建Maven项目:

Step1:

Step2:

Step3:这里选maven-archetype-webapp,因为后面的项目讲解都是web项目。如果是纯java项目,可以选择 maven-archetype-quickstart。

      

Step4:

Step5:右键项目,build path,修改jdk运行环境。

到这里,maven的web项目初建完毕。

修改:pom.xml


<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.elstar</groupId>
 <artifactId>spring</artifactId>
 <packaging>war</packaging>
 <version>0.0.1-SNAPSHOT</version>
 <name>spring Maven Webapp</name>
 <url>http://maven.apache.org</url>
 
 <!-- jar包版本控制 -->
 <properties>
  <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
   <junit.version>4.12</junit.version>
   <spring.version>4.3.3.RELEASE</spring.version>
 </properties>  
 <dependencies>
   <!-- junit支持 -->
  <dependency>
   <groupId>junit</groupId>
   <artifactId>junit</artifactId>
   <version>${junit.version}</version>
   <scope>test</scope>
  </dependency>
  <!-- spring支持 -->
  <dependency>
    <groupId>org.springframework</groupId>
    <artifactId>spring-context</artifactId>
    <version>${spring.version}</version>
  </dependency>
  <!-- spring测试支持 -->
  <dependency>
    <groupId>org.springframework</groupId>
    <artifactId>spring-test</artifactId>
    <version>${spring.version}</version>
  </dependency>
 </dependencies>
 <build>
  <finalName>spring</finalName>
 </build>
</project>

添加spring配置文件:src/main/resources/applicationContext.xml


<?xml version="1.0" encoding="UTF-8"?>  
<beans xmlns="http://www.springframework.org/schema/beans"  
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"  
  xmlns:p="http://www.springframework.org/schema/p" 
  xmlns:aop="http://www.springframework.org/schema/aop"  
  xmlns:context="http://www.springframework.org/schema/context" 
  xmlns:jee="http://www.springframework.org/schema/jee" 
  xmlns:tx="http://www.springframework.org/schema/tx" 
  xsi:schemaLocation="  
    http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-4.0.xsd 
    http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-4.0.xsd 
    http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-4.0.xsd 
    http://www.springframework.org/schema/jee http://www.springframework.org/schema/jee/spring-jee-4.0.xsd 
    http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-4.0.xsd">  
    
</beans>

以上这篇maven搭建spring项目(图文教程)就是小编分享给大家的全部内容了,希望能给大家一个参考,也希望大家多多支持PHPERZ。



最新网友评论  共有(0)条评论 发布评论 返回顶部

Copyright © 2007-2017 PHPERZ.COM All Rights Reserved   冀ICP备14009818号  版权声明  广告服务