1.注解种类
@Component(value="student") @Service @Repository @Controller
2.使用注解扫描包
<context:component-scan base-package="com.cj"></context:component-scan>
package com.cj.spring5; import org.springframework.stereotype.Component; @Component(value="student") public class Student { private String name; @Override public String toString() { return "Student{" + "name='" + name + '\'' + '}'; } }
标签:name,Component,String,bean,Student,注解,ioc,spring5 From: https://www.cnblogs.com/cciscc/p/16602774.html