Spring注解大全
解耦思想:编译不耦合,运行耦合
Spring注解大全
@Configuration @ComponentScan("com.itheima") @PropertySource("classpath:jdbc.properties") @Value("${jdbc.username}") ---------------------- == 创建bean对象,并存放到IOC容器 @Component @Controller @Service @Repository @Bean == 注入数据 @Autowired @Qualifier @Resource @Value == bean相关配置 @Scope @PostConstruct @PreDestroy ----------------------
依赖
<packaging>jar</packaging> <!--依赖包--> <dependencies> <!--spring ioc依赖--> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-context</artifactId> <version>5.0.2.RELEASE</version> </dependency> <!--spring jdbc依赖--> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-jdbc</artifactId> <version>5.0.2.RELEASE</version> </dependency> <!-- mysql数据库依赖 --> <dependency> <groupId>mysql</groupId> <artifactId>mysql-connector-java</artifactId> <version>5.1.40</version> </dependency> </dependencies>