2023-09-07
package com.hh.config; import org.springframework.context.annotation.ComponentScan; import org.springframework.context.annotation.Configuration; /** * @author hh * @version 1.0 * @DATE 2023-09-07 12:14:10 */ @Configuration @ComponentScan("com.hh") public class SpringConfig { }
测试访问
import com.hh.config.SpringConfig; import com.hh.dao.BookDao; import org.springframework.context.annotation.AnnotationConfigApplicationContext; /** * @author hh * @version 1.0 * @DATE 2023-09-07 12:14:54 */ public class App2 { public static void main(String[] args) { AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext(SpringConfig.class); BookDao bean = context.getBean(BookDao.class); bean.save(); } }
标签:xml,applicationContext,hh,context,注解,import,SpringConfig,com,class From: https://www.cnblogs.com/isDaHua/p/17684503.html