Spring类注解配置文件

Time: 2024-05-16 Thursday 11:02:01
Author: Jackasher

Spring类注解配置文件

在config的类标Config注解,组件扫描时会获取

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
package org.example.service;

import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.EnableAspectJAutoProxy;

/**
* @author Jackasher
* @version 1.0
* @className SpringConfig
* @since 1.0
**/
@Configuration
@ComponentScan({"org.example.service"})
@EnableAspectJAutoProxy(proxyTargetClass = true)
public class SpringConfig {
}

这是注解类作为参数

1
2
3
4
5
6
@Test
public void annotationTest(){
ApplicationContext applicationContext = new AnnotationConfigApplicationContext(SpringConfig.class);
UserService userService = applicationContext.getBean("userService", UserService.class);
userService.login();
}

Spring类注解配置文件
http://example.com/2024/05/16/Spring类注解配置文件/
作者
Jack Asher
发布于
2024年5月16日
许可协议