Skip to content

Commit

Permalink
new post
Browse files Browse the repository at this point in the history
  • Loading branch information
YangSeungHwa committed Jan 20, 2024
1 parent 9db0d9b commit 40e1ddf
Show file tree
Hide file tree
Showing 36 changed files with 585 additions and 23 deletions.
72 changes: 58 additions & 14 deletions _posts/2023-09-17-spring-SpringMVC 구현.md
Original file line number Diff line number Diff line change
Expand Up @@ -72,37 +72,66 @@ test {
```JAVA
public class ApplicationInitializer implements WebApplicationInitializer {
@Override
public void onStartup(javax.servlet.ServletContext servletContext) throws ServletException {
public void onStartup(ServletContext servletContext) throws ServletException {

AnnotationConfigWebApplicationContext context = new AnnotationConfigWebApplicationContext();
context.register(SampleConfiguration.class);
AnnotationConfigWebApplicationContext webContext = new AnnotationConfigWebApplicationContext();
webContext.register(WebConfigration.class);

DispatcherServlet dispatcherServlet = new DispatcherServlet(context);
AnnotationConfigWebApplicationContext apiContext = new AnnotationConfigWebApplicationContext();
apiContext.register(APIConfiguration.class);

ServletRegistration.Dynamic dispatcher = servletContext.addServlet("dispatcher", dispatcherServlet);
dispatcher.addMapping("/");
DispatcherServlet webDispatcherServlet = new DispatcherServlet(webContext);
DispatcherServlet apiDispatcherServlet = new DispatcherServlet(apiContext);

ServletRegistration.Dynamic webDispatcher = servletContext.addServlet("webDispatcher", webDispatcherServlet);
webDispatcher.addMapping("/web/*");

ServletRegistration.Dynamic apiDispatcher = servletContext.addServlet("apiDispatcher", apiDispatcherServlet);
apiDispatcher.addMapping("/api/*");
}
}
```

- API Listener만 추가하는 방법

```java
@Override
public void onStartup(ServletContext servletContext) throws ServletException {
AnnotationConfigWebApplicationContext rootContext = new AnnotationConfigWebApplicationContext();
rootContext.register(APIConfiguration.class);

// Manage the lifecycle of the root application context
servletContext.addListener(new ContextLoaderListener(rootContext));

AnnotationConfigWebApplicationContext dispatcherContext = new AnnotationConfigWebApplicationContext();
dispatcherContext.register(WebConfigration.class);

// Register and map the dispatcher servlet
ServletRegistration.Dynamic dispatcher =
servletContext.addServlet("web", new DispatcherServlet(dispatcherContext));
//dispatcher.setLoadOnStartup(1);
dispatcher.addMapping("/");
}
```

- DispatcherServlet 등록 필수!

### Configuration
- RESTAPI 설정

```JAVA
@Configuration
@ComponentScan(basePackages = "spring.sample")
public class SampleConfiguration {
@ComponentScan(basePackages = "org.infinity.server.controller.api")
public class APIConfiguration {
}
```

- Web설정

```java
@EnableWebMvc
@ComponentScan(basePackages = "<패키지명>")
public class SampleConfiguration implements WebMvcConfigurer {
@EnableWebMvc
@ComponentScan(basePackages = "org.infinity.server.controller.web")
public class WebConfigration implements WebMvcConfigurer {
@Override
public void configureViewResolvers(ViewResolverRegistry registry) {
InternalResourceViewResolver resolver = new InternalResourceViewResolver();
Expand All @@ -114,15 +143,30 @@ public class SampleConfiguration implements WebMvcConfigurer {
```

### Test Controller
- API Test

```java
@Controller
@RequestMapping("/test")
public class apiTestController {
@GetMapping("")
@ResponseBody
public String testString(){
return "test";
}
}
```

- View Test

```java
@Controller
@RequestMapping("/main")
public class IndexWebContoller {
@RequestMapping("/test")
public class webController {
@GetMapping("")
public ModelAndView getMainPage(){
ModelAndView mv = new ModelAndView();
mv.setViewName("/index");
mv.setViewName("test");
return mv;
}
}
Expand Down
17 changes: 11 additions & 6 deletions _posts/2023-09-28-githubblog-Github Blog 만들기.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,10 @@ last_modified_at: 2023-09-28T08:00:00-10:00:00
# 내용

## 필요한 Utility / Tool
- git
- Git
- SourceTree

### Jekyll 테마 사용을 위해 필요
### Jekyll 테마 Utility
- Ruby
- Jekyll 과 Bundler

Expand All @@ -44,9 +45,14 @@ last_modified_at: 2023-09-28T08:00:00-10:00:00

![image](../../assets/images/GitRepositoryUrl.png)

위와 같이 url을 복사하여
위와 같이 url 복사 후 SourceTree에서 Clone을 진행한다.

![image](../../assets/images/CloneBlogRepository.png)소스 Clone!
![image](../../assets/images/CloneBlogRepository.png)

>
> SourceTree 대신 Git GUI Client를 사용해도 무방하다
[Git GUI Client 다운로드 링크](https://git-scm.com/download/gui/windows)

### Ruby 설치

Expand Down Expand Up @@ -109,5 +115,4 @@ last_modified_at: 2023-09-28T08:00:00-10:00:00

# 연결문서
- [Post Blog Content](../../githubblog/githubblog-Post-Blog-Content)
- [Blog Comment 적용](../../githubblog/githubblog-Blog-Comment-적용)

- [Blog Comment 적용](../../githubblog/githubblog-Blog-Comment-적용)
2 changes: 2 additions & 0 deletions _posts/2023-10-02-할일-해야할일.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ last_modified_at: 2023-10-02T08:00:00-10:00:00
- [ ] TripGG Api 만들기
- [ ] Spring MVC 단위테스트 만들기
- [ ] 옵시디언 확장 개발해보기..
- [ ] multipart post
- [ ] @RequestBody post

---

Expand Down
10 changes: 9 additions & 1 deletion _posts/2023-10-11-oracle-Oracle Function.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,15 @@ NVL(name, 0)
```sql
NVL2(comm, 'Y', 'N')
```
---

### REPLACE
- REPLACE(<컬럼명>, <변경대상 문자열>, <변경결과 문자열>)

```SQL
UPDATE mytable SET FILE_PATH = REPLACE(FILE_PATH, '\\', '\/')
```

- ---

# 연결문서
- [CommonDB](../../database/database-CommonDB)
Expand Down
1 change: 1 addition & 0 deletions _posts/2023-10-17-cli-Window Command Detail.md
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ tasklist /V
- 서비스 관련 CLI

#### sc delete \<서비스명\>
- 서비스 삭제
- **관리자 콘솔로만 사용 가능**

### tree
Expand Down
6 changes: 5 additions & 1 deletion _posts/2023-12-08-spring-Filter.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,11 @@ last_modified_at: 2023-12-08T08:00:00-10:00:00

# 내용

## 역할
- J2EE 표준 스펙 기능으로 [DispatcherServlet](../../spring/spring-DispatcherServlet)에 요청이 전달되기 전/후에 url 패턴에 맞는 모든 요청에 대한 부가작업 처리

## 특징
- DispatcherServlet에 요청이 전달되지 전, 후에 url 패턴에 맞는 모든 요청에 대한 처리
- DispatcherServlet에 요청이 전달되기 전, 후에 url 패턴에 맞는 모든 요청에 대한 처리
- 스프링과 무관하게 전역적으로 처리해야 할 작업 수행
- ServletRequest/ServletResponse 객체를 조작 가능
- 웹 컨테이너에 의해 관리됨
Expand Down Expand Up @@ -67,3 +70,4 @@ public class SampleFilter1 implements Filter{
---

# 연결문서
- [SpringMVC](../../spring/spring-SpringMVC)
3 changes: 2 additions & 1 deletion _posts/2023-12-15-spring-DispatcherServlet.md
Original file line number Diff line number Diff line change
Expand Up @@ -89,4 +89,5 @@ public LocaleResolver localeResolver() {
---

# 연결문서
- [WebMvcConfigurer](../../spring/spring-WebMvcConfigurer)
- [WebMvcConfigurer](../../spring/spring-WebMvcConfigurer)
- [SpringMVC](../../spring/spring-SpringMVC)
1 change: 1 addition & 0 deletions _posts/2024-01-03-itbusiness-RFP.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,3 +31,4 @@ last_modified_at: 2024-01-03T08:00:00-10:00:00
---

# 연결문서
- [RNR](../../itbusiness/itbusiness-RNR)
29 changes: 29 additions & 0 deletions _posts/2024-01-04-itbusiness-BMT.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
---
title : "BMT"
excerpt : "BMT"
toc : true
toc_sticky : true
toc_label : "BMT"
categories:
- ITBusiness
tags:
- [ITBusiness]
last_modified_at: 2024-01-04T08:00:00-10:00:00
---

# 날짜 : 2024-01-04 18:39

# 태그 : #ITBusiness
---

# 내용

## 정의
> BMT 란?
> Benchmark Test
> 품질 성능 평가 시험
> 실존하는 비교 대상을 두고 하드웨어나 소프트웨어의 성능을 비교 분석하여 평가하는것
---

# 연결문서
81 changes: 81 additions & 0 deletions _posts/[email protected]
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
---
title : "@Autowired"
excerpt : "@Autowired"
toc : true
toc_sticky : true
toc_label : "@Autowired"
categories:
- Annotation
tags:
- [Spring, Annotation]
last_modified_at: 2024-01-05T08:00:00-10:00:00
---

# 날짜 : 2024-01-05 18:14

# 태그 : #Spring #Annotation
---

# 내용

## Artifact
- spring-beans

## 역할
- 필요한 의존 객체의 타입에 해당하는 bean을 찾아 주입
- 동일한 Bean이 2개 이상이면 오류를 발생
- 두 개 이상의 클래스로 하나의 인터페이스를 구현할 경우 [@Qualifier](../../annotation/annotation-@Qualifier) Annotation으로 특정 Bean을 가져오겠다는 명시 필요

## 적용 대상
- Constructor
- Setter
- Field

## DI 방법

### Constructor Injection
- 가장 권장되는 방식의 DI 방식
- 생성자에서 의존성을 주입받고자 하는 field를 나열하는 방법
- 매개변수가 bean으로 등록되어있지 않다면 생성자에서 에러 발생

```java
@Service
public class MyService {
private MyDao myRepository;

@Autowired
public MyService(MyRepository myRepository) {
this.myRepository = myRepository;
}
}
```

### Setter Injection
- setter 메소드에 @Autowired annotation을 선언

```java
@Service
public class MyService {
private MyDao myRepository;

@Autowired
public setMyRepository(MyRepository myRepository) {
this.myRepository = myRepository;
}
}
```

### Field Injection
- 단일 책임의 원칙 위반, 객체의 오염 가능성이 있다는 단점
- 사용하기 쉽다는 장점
- field에 @Autowired annotation을 선언

```java
@Autowired
private ConfigValueWebService configValueWebService;
```

---

# 연결문서
- [@Qualifier](../../annotation/annotation-@Qualifier)
Loading

0 comments on commit 40e1ddf

Please sign in to comment.