- 使用@Component、@Service、@Controller、@Repository等在自定义类上并在spring.xml配置类似
<context:component-scan base-package="edu.xlh.pojo02"/>
就可以交给spring管理,同时默认bean的id为类名全小写,如果要id自定义,就要诸如@Component(“a”),bean的id就是a。 - 没有@Component、@Service、@Controller、@Repository等在自定义类上就没有交给spring管理,那么spring中底层以set注入的@Value(value="")或者@Value("")就无法生效。
大三东软暑期实训-spring篇2
最新推荐文章于 2022-09-03 20:59:27 发布