Spring框架简介 Spring Framework Introduction
2016-08-14 10:47
323 查看
Introduction
The Spring Framework provides a comprehensive programming and configuration model for modern Java-based enterprise applications - on any kind of deployment platform. A key element of Spring is infrastructural support at the application level: Spring focuses on the "plumbing" of enterprise applications so that teams can focus on application-level business logic, without unnecessary ties to specific deployment environments.Features
Dependency InjectionAspect-Oriented Programming including Spring's declarative transaction management
Spring MVC web application and RESTful web service framework
Foundational support for JDBC, JPA, JMS
Much more…
All avaible features and modules are described in the Modules section of the reference documentation. Their maven/gradle coordinates are also described there.
Minimum requirements
JDK 6+ for Spring Framework 4.xJDK 5+ for Spring Framework 3.x
Quick Start
Download()
()
()
()
()
()
4.3.2
MAVEN
GRADLE
The recommended way to get started using
spring-frameworkin your project is with a dependency management system – the snippet below can be copied and pasted into your build. Need help? See our getting started guides on building with Maven and Gradle.
<dependencies> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-context</artifactId> <version>4.3.2.RELEASE</version> </dependency> </dependencies>
Spring Framework includes a number of different modules. Here we are showing
spring-contextwhich provides core functionality. Refer to the getting started guides on the right for other options.
Once you've set up your build with the
spring-contextdependency, you'll be able to do the following:
hello/MessageService.java
package hello; public interface MessageService { String getMessage(); }
hello/MessagePrinter.java
package hello; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; @Component public class MessagePrinter { final private MessageService service; @Autowired public MessagePrinter(MessageService service) { this.service = service; } public void printMessage() { System.out.println(this.service.getMessage()); } }
hello/Application.java
package hello; import org.springframework.context.ApplicationContext; import org.springframework.context.annotation.*; @Configuration @ComponentScan public class Application { @Bean MessageService mockMessageService() { return new MessageService() { public String getMessage() { return "Hello World!"; } }; } public static void main(String[] args) { ApplicationContext context = new AnnotationConfigApplicationContext(Application.class); MessagePrinter printer = context.getBean(MessagePrinter.class); printer.printMessage(); } }
The example above shows the basic concept of dependency injection, the
MessagePrinteris decoupled from the
MessageServiceimplementation, with Spring Framework wiring everything together.
from: http://projects.spring.io/spring-framework/#quick-start
相关文章推荐
- Spring框架简介 Spring Framework Introduction
- Introduction to the spring framework(Spring框架简介)
- Preview of Spring-framework :Spring框架的预习和自我整理
- 一、Framework 简介(Introduction to Framework Programming Guide)
- Spring Framework Reference Documentation-spring框架参考文档-part3
- Spring框架学习(1)Spring简介
- Spring框架核心之(一)Spring简介
- Introduction to the Spring Framework 2005年5月版 完整翻译
- Spring框架错误之org.springframework.beans.factory.BeanCreationException
- Spring AOP之Introduction(@DeclareParents)简介
- 【spring框架】spring简介和需要的jar包
- OverView of Spring Framework(综述Spring框架)
- Spring Framework Reference Documentation-spring框架参考文档-part1
- Spring.NET的IoC容器(The IoC container)——简介(Introduction)
- Spring AOP之Introduction(@DeclareParents)简介
- Spring笔记——Spring框架简介和初次框架配置
- 错误中学习--spring框架 org.springframework.beans.factory.NoSuchBeanDefinitionException
- Spring框架联系出现log4j:WARN No appenders could be found for logger (org.springframework.core.env.Standard
- Spring Framework Ecosystem – Introduction to Spring Projects
- Spring-Framework启动简介