创建配置类
如题,前例使用xml文件加载bean类,然后通过每个bean的id获取bean实例。注解@ComponentScan注解默认就会装配标识了@Controller,@Service,@Repository,@Component注解的类到spring容器中,功能同xml问价加载bean类。
注解@Configuration标注为配置类。
注解@ComponentScan指定扫描范围
配置类
package com.annotation.config;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
/* *
* @copyright 2003-2025
* @author qiao wei
* @date 2025-06-13
* @version 1.0
* @brief
* @history name
* date
* brief
*/
@Configuration
@ComponentScan(basePackages = {
"com.annotation.thirdjar",
"com.annotation.dao.impl"}
)
public class ConfigForDateForamt02 {
}
订阅专栏 解锁全文
1万+


&spm=1001.2101.3001.11974&articleId=148633247&d=1&t=3&u=8110cb3b589e450c8372361ab89f493c)

被折叠的 条评论
为什么被折叠?



