728x90
개요: Class를 생성해 getter, setter 없이 바로 사용할 수 있게 해준다.
record Person(String name, int age) {};
record Address(String firstLine, String city) {};
@Configuration
public class HelloWorldConfiguration {
@Bean
public String name() {
return "Ranga";
}
@Bean
public int age() {
return 15;
}
@Bean
public Person person() {
return new Person("tomhoon", 30);
}
@Bean(name = "address2")
public Address address() {
return new Address("bakerStreet", "Anyang");
}
}
여기서는
SpringContext 영역에서 record를 선언하여 바로 사용함.
'서버' 카테고리의 다른 글
Spring boot - Context Bean 생성하기 실습 (1) | 2024.08.22 |
---|---|
Springboot - context의 bean 생성시 기존 메소드 사용하기 (0) | 2024.08.22 |
Springboot - Spring Context 다루기 (0) | 2024.08.22 |
github action - 자체 runner 내 컴퓨터에다가 생성하기 (0) | 2024.08.21 |
Spring boot) security모듈 있을 때와 없을 때 config처리방식(cors, csrf) (0) | 2024.08.15 |