spring 注解开发
2021-04-14 06:30
标签:conf https component can ati type 注解 XML name 一、环境 1、导入包 maven 2、xml配置文件 二、具体实现 1、bean 2、属性注入 3、衍生注解 dao [@Repository] service [@Service] controller[@Controller] 将类注入到spring容器中 4、自动装配注解 5、作用域注解 @Scope spring 注解开发 标签:conf https component can ati type 注解 XML name 原文地址:https://www.cnblogs.com/wt7018/p/13338118.htmlxml version="1.0" encoding="UTF-8"?>
beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:context="http://www.springframework.org/schema/context"
xsi:schemaLocation="http://www.springframework.org/schema/beans
https://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/context
https://www.springframework.org/schema/context/spring-context.xsd">
context:component-scan base-package="com.wt.pojo"/>
context:annotation-config/>
beans>
@Component
public class User {
}
package com.wt.pojo;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;
@Component
public class User {
@Value("wt")
private String name;
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
}