DI 적용 X
@restcontroller
public class mycontroller {
private myservice service = new myservice();
@requestmapping("/welcome")
public string welcome() {
return service.retrievewelcomemessage();
}
}
DI 예시
@component
public class myservice {
public string retrievewelcomemessage(){
return "welcome to innovationm";
}
}
@restcontroller
public class mycontroller {
@autowired
private myservice service;
@requestmapping("/welcome")
public string welcome() {
return service.retrievewelcomemessage();
}
}
DI는 코드간 결합도를 낮춘다.
임시
https://dzone.com/articles/spring-vs-spring-boot
Spring vs. Spring Boot: A Comparison of These Java Frameworks - DZone Java
In this post, we compare and contrast the two most popular Java frameworks — Spring and Spring Boot — to demonstrate the types of problems that they solve.
dzone.com
'JAVA' 카테고리의 다른 글
Spring boot - Redis 연동 및 Ec2 환경 구축. (0) | 2022.04.20 |
---|---|
@RequestParam List Map 형식 받기 (Spring 리스트 맵 파라미터 받기 ) (0) | 2022.02.08 |
Active MQ (0) | 2022.01.13 |