通过注解实现ServiceImpl业务
一、使用@Component装配Bean
1、 定义类:User
在类上面加@Component注解,在属性上面加@Value值
package com.wbg.springxmlbean.entity; import org.springframework.beans.factory.annotation.Value; import org.springframework.stereotype.Component; @Component(value = "user") public class User { @Value("2") private int id; @Value("韦邦杠") private String name; @Value("18") private int age; private Role role; @Override public String toString() { return "User{" + "id=" + id + ", role=" + role + ", name='" + name + '\'' + ", age=" + age + '}'; } public Role getRole() { return role; } public void setRole(Role role) { this.role = role; } public int getId() { return id; } public void setId(int id) { this.id = id; } public String getName() { return name; } public void setName(String name) { this.name = name; } public int getAge() { return age; } public void setAge(int age) { this.age = age; } }