å¨Mavenä¸Springçåºç¡é
ç½®
Springæ¯é«åº¦æ¨¡ååçï¼å¯ä»¥åç¬ä½¿ç¨Springçæ个åºèä¸éè¦ä¾èµSpringçå ¶ä»åºãæ¯å¦ï¼ä½¿ç¨Spring Contextåºä¸éè¦ä¾èµSpring Persistenceæè Spring MVCåºã
让æ们å ä»æç®åå¼å§ï¼å¨Mavenä¸é ç½®spring-contextä¾èµï¼
<properties>ä¸ä¾å®ä¹ç对spring-contextçä¾èµï¼spring-contextå®ç°äºSpringæ³¨å ¥å®¹å¨å¹¶ä¸ä¾èµï¼spring-core,spring-expression,spring-aop以åspring-beansãè¿äºä¾èµå 使容å¨å¯ä»¥æ¯æSpringçä¸äºæ ¸å¿ææ¯ï¼Springæ ¸å¿ç»ä»¶,Spring ELè¡¨è¾¾å¼ (SpEL), é¢ååé¢ç¼ç¨,JavaBeanæºå¶ã
注æï¼å¨runtimeèå´å®ä¹è¿ä¸ªä¾èµï¼å æ¤éæ±ç¡®å®å¨ç¼è¯æé´ä¸éè¦ä¾èµç¸å ³Springç¹å®çAPIãå¨ä¸äºé«çº§åºç¨åºæ¯ä¸ï¼ä¸äºSpringä¾èµé¡¹å¯ä»¥ä¸ç¨é ç½®runtimeèå´ï¼ä½æ¯å¨ç®åæ¯è¾ç®åç项ç®åºæ¯ä¸ï¼ä¸éè¦é对Springç¼è¯é¡¹ç®å»è·å¾æ´ä¸ªæ¡æ¶çå ¨é¨åè½ã
åæ ·è¦æ³¨æçæ¯ï¼ä»Spring 3.2å¼å§ä¸éè¦å®ä¹CGLIBä¾èµï¼ç®åççæ¬æ¯CGLIB 3.0ï¼ãç°å¨ä½¿ç¨å åµå¨spring-core JARï¼æ´å¤è¯¦ç»ä¿¡æ¯å¯ä»¥æ¥çç¸å ³[JIRA]https://jira.springsource.org/browse/SPR-9669("JIRA")ä¸çcglibå ï¼net.sf.cglibç°å¨ä½¿ç¨org.springframework.cglibæ¿ä»£ï¼ã
å¨Mavené ç½®Springæä¹ åæ¡æ¶
ç°å¨æ¥ççSpringæä¹ åæ¡æ¶çé ç½®ï¼ä¸»è¦æ¯spring-ormï¼
<dependency>ä¸é¢çé ç½®å¢å äºHibernateåJPAåè½æ¯æï¼æ¯å¦HibernateTemplateåJpaTemplate以åä¸äºé¢å¤çæä¹ åç¸å ³çä¾èµï¼spring-jdbcåspring-tx
å¨JDBCæ°æ®è®¿é®åºå®ä¹Spring JDBCæ¯æ以åJdbcTemplateï¼Spring-txæä¾äºé常çµæ´»çäºå¡ç®¡çæ½è±¡ã
å¨Mavené ç½®Spring MVC
è¦å¢å Spring WebåServletæ¯æï¼éè¦å¨ä¸é¢å·²é ç½®çpomæ件ä¸é¢å¤å¢å 两个ä¾èµï¼
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-web</artifactId>
<version>${org.springframework.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-webmvc</artifactId>
<version>${org.springframework.version}</version>
</dependency>
spring-webå å å«ServletåPortletæéè¦éç¨ç»ä»¶ï¼spring-webmvcåå¨Servletç¯å¢ä¸å¯ç¨MVCæ¯æã
ç±äºspring-webmvcä¾èµäºspring-webï¼æ以å®ä¹äºspring-webmvcä¾èµåï¼å¯ä»¥ä¸ç¨æ¾ç¤ºçå¨pomå®ä¹spring-webã
å¨Mavenä¸é
ç½®Spring Test
å¯ä»¥éè¿ä¸é¢çä¾èµé ç½®å°Spring Testå¼å ¥é¡¹ç®
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-test</artifactId>
<version>${spring.version}</version>
<scope>test</scope>
</dependency>
ä»Spring 3.2å¼å§ï¼Spring MVC Test项ç®å·²ç»è¢«å å«å°æ ¸å¿çSpring Testæ¡æ¶ä¸ï¼åæ¥æ¯ä¸ä¸ªç¬ç«é¡¹ç®ï¼é¡¹ç®æ管å¨GitHubï¼ãæ以ï¼ä»Spring 3.2å¼å§ï¼ä» éè¦å¨ä¾èµé ç½®ä¸é ç½®spring-testä¾èµå³å¯ã
注æï¼å¯¹äºä½¿ç¨Spring 3.1å以ä¸çæ¬çåºç¨æ¥è¯´ï¼ç¬ç«çspring-mvc-testä¾èµè¿æ¯å¯ä»¥ä½¿ç¨çï¼å¯ä»¥åèè¿éè¿è¡é ç½®ãä½æ¯ï¼è¿ä¸ªä¾èµå·²ç»ä¸åMavençä¸å¤®åºä¸ï¼æ以å¦æéè¦å¢å ä¾èµéè¦é ç½®èªå®ä¹Maven容å¨ã
7. 使ç¨Milestonesï¼éç¨ç¢ï¼çæ¬
Springçææ°ç¨³å®çæ¬ä¿åå¨Mavençä¸å¤®åºï¼å¦æ项ç®éè¦ä½¿ç¨Springçéç¨ç¢çæ¬ï¼éè¦å¨pomä¸é ç½®èªå®ä¹å®¹å¨ï¼
<repositories>
<repository>
<id>repository.springframework.maven.milestone</id>
<name>Spring Framework Maven Milestone Repository</name>
<url>http://repo.spring.io/milestone/</url>
</repository>
</repositories>
å½å®¹å¨é ç½®å®æåï¼é¡¹ç®å°±å¯ä»¥åä¸é¢ç¤ºä¾ä¸æ ·å®ä¹ä¾èµäºï¼
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-core</artifactId>
<version>3.2.0.RC2</version>
</dependency>
8. 使ç¨Snapshotsï¼å¿«ç §ï¼çæ¬
ä¸éç¨ç¢çæ¬ä¸æ ·ï¼å¿«ç §çæ¬ä¹éè¦é ç½®èªå®ä¹å®¹å¨ä½ç½®ï¼
<repositories>
<repository>
<id>repository.springframework.maven.snapshot</id>
<name>Spring Framework Maven Snapshot Repository</name>
<url>http://repo.spring.io/snapshot/</url>
</repository>
</repositories>
å½å¿«ç §å®¹å¨ä½ç½®é ç½®å®æåï¼ä¸é¢çä¾èµé 置就å¯ä»¥ä½¿ç¨äºï¼
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-core</artifactId>
<version>3.3.0.BUILD-SNAPSHOT</version>
</dependency>
对äº4.xçæ¬ä¹æ¯ä¸æ ·çï¼
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-core</artifactId>
<version>4.0.3.BUILD-SNAPSHOT</version>
</dependency>