월 17,600원
5개월 할부 시다른 수강생들이 자주 물어보는 질문이 궁금하신가요?
- 미해결Spring Cloud로 개발하는 마이크로서비스 애플리케이션(MSA)
docker 생성 후 gateway userservice 연결 시 에러
게이트 웨이를 도커에만 올리면 에러가 나옵니다 500 Server Error for HTTP POST "/user-service/login"io.netty.channel.AbstractChannel$AnnotatedConnectException: Connection refused: /127.0.0.1:8889 유레카에서 유저 서비스 클릭 시 : /127.0.0.1:8889요렇게 나오는데 http://localhost:8888/user-service/default에서는{token.expireDate: 20002666,order_service.url: "http://order-service/order-service/%s/orders",order_service.exception.user_empty: "user's ord exist3333",user_service.url: "http://user-service/user",user_service.exception.user_empty: "user_Empty",token.secret: "1234"}gateway.host: "172.18.0.6",token.expireDate: 20002666,이렇게 나옵니다 http://localhost:8000/user-service/default이건 에러가 나구요도커의 네트워크는 추가 했구요"Containers": { "11a12dd45aaa3274226b1b462e1997b50e9b7ed61b405595c0c3b89393d6e036": { "Name": "rabbitmq", "EndpointID": "3425a23e5c021d2bcc307bed1d9b4ac03c17b92d4828f8b633469d8bbe8df8ac", "MacAddress": "02:42:ac:12:00:04", "IPv4Address": "172.18.0.4/16", "IPv6Address": "" }, "28da3474585596f6a3a435e48cfc9084e7d397fafaea751537ac7c82ac81bfd1": { "Name": "user-service1", "EndpointID": "543022aef70070d571f9d193151af692e59c5bc752feb15b5a0d75d23338ff34", "MacAddress": "02:42:ac:12:00:03", "IPv4Address": "172.18.0.3/16", }, "47dbfe92f425d933ca6e72018eb11b95f0cba48434be9b28f571570787db0d02": { "Name": "gateway-service", "EndpointID": "f3cfa36a9b73a2a925d62f0d8045d51dd8bdb4afe3b2926cae6a4997bac92114", "MacAddress": "02:42:ac:12:00:06", "IPv4Address": "172.18.0.6/16", "IPv6Address": "" }, "b4910d66fee36364691710a189c79f47c2a7fac7675166bbb102b6dfba83ef80": { "Name": "eureka", "EndpointID": "23d981be13ce1a1e7f1f4b85ea61553a13d73dfcf5af6039e6befa68d0cea497", "MacAddress": "02:42:ac:12:00:02", "IPv4Address": "172.18.0.2/16", "IPv6Address": "" }, "e5326aa441bdcf8133c66384251212b14d1d0a452291a462a667de21e3f23c6c": { "Name": "config", "EndpointID": "5f8de35288b1d51927f840e050203671ff0c880b0b8f39c2dd614055c49306bc", "MacAddress": "02:42:ac:12:00:05", "IPv4Address": "172.18.0.5/16", "IPv6Address": "" } 어디가 문제일까요?
- 해결됨Spring Cloud로 개발하는 마이크로서비스 애플리케이션(MSA)
JWT 토큰 유효성 검사
안녕하세요! 좋은 강의 제공해주셔서 감사합니다. 다름이 아니라, 수업에서 JWT 토큰 유효성 로직을 api gateway service에 구현했는데, user-service가 아닌 gateway service에 구현한 이유가 있을까요? api gateway에 토큰 유효성 로직을 구현하게 되면, 만료된 토큰으로 api gateway를 거치지 않고 바로 user-service에 요청하는 경우, 토큰 유효성 검사를 하지 않아서 문제가 발생할 수 있지 않나요?
- 미해결Spring Cloud로 개발하는 마이크로서비스 애플리케이션(MSA)
JWT Token SigningKey 관련 질문
안녕하세요. 강의를 수강하던 중 이해하기 힘든 현상을 발견되어 이렇게 질문드립니다.Jwt는 SigningKey로 복호화가 가능하다면, 유효한 토큰이다.(유효한 토큰이다란 기준이 여러 개 있습니다만) 라고 알고 있는데요. 아래와 같은 현상을 발견하게되서 질문하게 되었습니다.(현재 Gateway server - token.secret = A)(현재 User service - token.secret = A)1.User-service 회원생성2.User-service 로그인 (응답에서 jwt토큰 복사)로그인 시 User-service의 token.secret을 SigningKey로 jwt 토큰 발급3.Gateway의 AuthorizationHeaderFilter를 통과하는 user-service/actuator/health 호출 (response, 200)여기까지는 정상입니다만4.ecommerce.yml의 token.secret 변경 및 커밋5.Gateway의 /refresh 호출액츄에이터에 의한 token.secret 변경 (현재 Gateway server - token.secret = B)(현재 User service - token.secret = A)(현재 JWT 토큰의 SigningKey = A)6.Gateway의 AuthorizationHeaderFilter를 통과하는 user-service/actuator/health 호출 (response, 200) 여기가 질문 포인트입니다. AuthorizationHeaderFilter의 isJwtValid의 코드를 보면subject = Jwts.parser().setSigningKey(env.getProperty("token.secret")) .parseClaimsJws(jwt).getBody() .getSubject();이런 구문이 있습니다. Jwt 생성 당시의 Siginingkey랑 다른 signingkey로 복호화하면 오류가 나면서 인가에 실패하는 것을 기대했습니다. 하지만 왜 정상적으로 200을 반환하는지 이해가 잘 되지 않습니다. (Gateway의 token.secret은 B로 변경됨을 로그로 확인했습니다. )
- 해결됨Spring Cloud로 개발하는 마이크로서비스 애플리케이션(MSA)
H2 console 에서의 문제
안녕하세요.먼저 좋은 수업을 강의 해주셔서 감사합니다!다름이 아니라 제가 해당 수업 진행 중 오류가 있어서 문의드립니다!mysql 콘솔에서는 오류가 발생 하지 않았으나,H2 Console 에서 테이블을 조회시 SELECT * FROM ORDERS;(conn=42) Table 'mydb.ORDERS' doesn't exist 42S02/1146 이러한 에러가 발생하는데 원인이 무엇일까요??order-service 에서 조회시에는 문제가 없습니다..
- 해결됨Spring Cloud로 개발하는 마이크로서비스 애플리케이션(MSA)
GATEWAY-SERVICE 를 통하여 호출하지 않는 이유가 있을까요?
마이크로 서비스 사용간 (RestTemplate 혹은 Feign) 에서 Eureka 의 서비스 명으로 USER-SERVICE 같은 마이크로 서비스명을 통하여 직접 호출하면 결론적으로는 GATEWAY-SERVICE 를 통하여 사용했을때의 장점을 잃어버리는 것 같은데, 섹션 10 에서는 게이트웨이를 통하지 않고 직접 서비스를 호출하는 이유가 있을까요?
- 미해결Spring Cloud로 개발하는 마이크로서비스 애플리케이션(MSA)
MSA에서 데이터를 가져오는 방법
MSA에서 다른 어플리케이션의 데이터를 가져오는 방법으로 RestTemplate, FeignClient를 사용하는 방법을 알려주셨는데요.데이터를 가져오는 것은 보통 rest 통신을 사용하여 가져오나요?실무에서 카프카나 다른 라이브러리를 사용해서 가져오는지, 아니면 설명해주신 것 처럼 rest 통신을 통해 가져오는지 궁금합니다~
- 미해결Spring Cloud로 개발하는 마이크로서비스 애플리케이션(MSA)
Spring Security 최신버전(Spring Boot 3.X.X 대)의 WebSecurity 설정 공유드립니다.
최신버전으로 진행하다보니 막혔었는데요. 구글링, ChatGPT 등을 통해서 동작하는 코드 공유드립니다.정확한 구현은 아닐 수 있겠지만, 강의를 진행하는 데는 문제 없는 것 같습니다. 참고만 부탁드려요~ package com.example.userservice.security; import com.example.userservice.service.UserService; import lombok.RequiredArgsConstructor; import org.springframework.boot.autoconfigure.security.servlet.PathRequest; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import org.springframework.security.authentication.AuthenticationManager; import org.springframework.security.config.annotation.ObjectPostProcessor; import org.springframework.security.config.annotation.authentication.builders.AuthenticationManagerBuilder; import org.springframework.security.config.annotation.web.builders.HttpSecurity; import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity; import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder; import org.springframework.security.web.SecurityFilterChain; import org.springframework.security.web.util.matcher.IpAddressMatcher; @Configuration @EnableWebSecurity @RequiredArgsConstructor public class WebSecurity { private final UserService userService; private final BCryptPasswordEncoder bCryptPasswordEncoder; private final ObjectPostProcessor<Object> objectPostProcessor; private static final String[] WHITE_LIST = { "/users/**", "/", "/**" }; @Bean protected SecurityFilterChain config(HttpSecurity http) throws Exception { http.csrf().disable(); http.headers().frameOptions().disable(); http.authorizeHttpRequests(authorize -> { try { authorize .requestMatchers(WHITE_LIST).permitAll() .requestMatchers(PathRequest.toH2Console()).permitAll() .requestMatchers(new IpAddressMatcher("127.0.0.1")).permitAll() .and() .addFilter(getAuthenticationFilter()); } catch (Exception e) { e.printStackTrace(); } } ); return http.build(); } public AuthenticationManager authenticationManager(AuthenticationManagerBuilder auth) throws Exception { auth.userDetailsService(userService).passwordEncoder(bCryptPasswordEncoder); return auth.build(); } private AuthenticationFilter getAuthenticationFilter() throws Exception { AuthenticationFilter authenticationFilter = new AuthenticationFilter(); AuthenticationManagerBuilder builder = new AuthenticationManagerBuilder(objectPostProcessor); authenticationFilter.setAuthenticationManager(authenticationManager(builder)); return authenticationFilter; } } 이렇게 하시고 중요한 것이, Login Form을 사용하지 않기 때문에 AuthenticationFilter 클래스의 Override 메소드 중 successfulAuthentication 메소드 내부에super.successfulAuthentication(request, response, chain, authResult);코드가 작성되어 있다면, 아래처럼 제거 또는 주석 처리를 꼭 해야 합니다! (다른 질문 글에서 발견하였습니다, 공유 감사드립니다.)하지 않은 경우 에러가 발생하며 login 요청이 제대로 동작하지 않습니다. package com.example.userservice.security; import com.example.userservice.vo.RequestLogin; import com.fasterxml.jackson.databind.ObjectMapper; import jakarta.servlet.FilterChain; import jakarta.servlet.ServletException; import jakarta.servlet.http.HttpServletRequest; import jakarta.servlet.http.HttpServletResponse; import org.springframework.security.authentication.UsernamePasswordAuthenticationToken; import org.springframework.security.core.Authentication; import org.springframework.security.core.AuthenticationException; import org.springframework.security.web.authentication.UsernamePasswordAuthenticationFilter; import java.io.IOException; import java.util.ArrayList; public class AuthenticationFilter extends UsernamePasswordAuthenticationFilter { @Override public Authentication attemptAuthentication(HttpServletRequest request, HttpServletResponse response) throws AuthenticationException { try { RequestLogin creds = new ObjectMapper().readValue(request.getInputStream(), RequestLogin.class); return getAuthenticationManager().authenticate( new UsernamePasswordAuthenticationToken( creds.getEmail(), creds.getPassword(), new ArrayList<>() ) ); } catch (IOException e) { throw new RuntimeException(e); } } @Override protected void successfulAuthentication(HttpServletRequest request, HttpServletResponse response, FilterChain chain, Authentication authResult) throws IOException, ServletException { //super.successfulAuthentication(request, response, chain, authResult); } }
- 미해결Spring Cloud로 개발하는 마이크로서비스 애플리케이션(MSA)
Config Client의 설정정보 업데이트 원리
안녕하세요. 강의 잘 듣고 있습니다. 강의를 듣던 중 아래 몇 가지 이해가 부족한 부분과 조언이 필요한 부분이 있어 이렇게 질문 남깁니다. 제가 이해하기로, Spring Cloud Config는 애플리케이션의 환경정보(이하 env)를 외부로부터 받아오기 위한 의존성이며, Spring Actuator의 /refresh는 단지 env를 업데이트 하기 위해 사용하는것 뿐이다. 둘 사이의 종속적인 부분은 없어보인다. 식으로 이해를 했습니다. 제가 생각한 것이 맞는지 궁금합니다. 혹은 참고해서 공부할 수 있는 키워드가 있다면 참고하여 학습하도록 하겠습니다. @Component 어노테이션으로 Spring Bean이 등록이 될 때, @Value 어노테이션을 통해 환경정보를 주입받을 수 있는 것을 알고 있습니다. 직접 확인을 해보니 /refresh는 Environment의 값은 바꾸지만, @Value를 통해 주입된 필드값은 수정되지 않음을 볼 수 있었습니다.Spring Cloud Config를 도입한다고 하면 @Value를 통해 주입받던 모든 곳을 Environment를 통해 가져오는 것으로 수정을 해야하는지 혹은 다른 해결방안이 있는지 궁금합니다. 감사합니다.
- 미해결Spring Cloud로 개발하는 마이크로서비스 애플리케이션(MSA)
보상 트랜잭션의 대한 후속 강의 문의합니다.
강의를 다 들어가는데요~ msa에서 예외가 발생 시 보상 트랜잭션의 대한 후속 강의를 제작한다고 들었습니다!해당 후속 강의는 정말 중요한 강의라고 생각되는데.. 언제쯤 업데이트 하실 계획이실까요?
- 미해결Spring Cloud로 개발하는 마이크로서비스 애플리케이션(MSA)
application.yml args에러발생이유
강의 잘 듣고있습니다~실습으로 따라하면서 하고있는데 application.yml에서 에러가 발생하는데 왜 그런것일까요??
- 미해결Spring Cloud로 개발하는 마이크로서비스 애플리케이션(MSA)
스프링 시큐리티 문의 (webSecurityConfigurerAdapter 취소선)
안녕하세요. 스프링시큐리티 로그인관련 진행하다가 extends webSecurityConfigurerAdapter 가 취소선이 나와서 확인해보니 현재는 사용하지않는다고 알게되었습니다. 나름 바꾸면서 진행중인데authenticationManager() 를 사용하려면 어떻게해야되는지 알 수 있을까요?
- 미해결Spring Cloud로 개발하는 마이크로서비스 애플리케이션(MSA)
catalog 테이블 자동 create-drop 가 안됩니다.
안녕하세요 application.yml 설정을하고 서버 시작 시 CREATE문자체가 동작을안하는것같습니다.application.yml 과 CatalogEntity.java 는 다음과같습니다. 문제가무엇일까요...
- 미해결Spring Cloud로 개발하는 마이크로서비스 애플리케이션(MSA)
H2 최신 버전 사용 시 server mode 사용에 따른 application.yml 파일 설정(테이블은 생성됐는데 data.sql INSERT 안될 시 참고)
Spring Boot 3.XX 대 버전으로 최신 버전 사용 시 H2를 이전 버전으로 사용 불가합니다.따라서 H2를 따로 켜서 실행해준 후, catalog-service에서 Server mode로 연결하던지 따로 켜 둔 H2를 연결하던지 선택해야합니다. 이 때, Server Mode로 프로젝트와 H2를 연결시키면 강의 내용의 설정만으로는 data.sql의 INSERT 쿼리문이 동작하지 않습니다. 그렇기 때문에 관련 설정을 application.yml에 추가해주어야 하는데요. 아래와 같이 설정하면 됩니다. stackoverflow와 강사님의 2021년 답변을 참고하여 해결하였습니다. server: port: 0 spring: application: name: catalog-service h2: console: enabled: true settings: web-allow-others: true path: /h2-console datasource: driver-class-name: org.h2.Driver url: jdbc:h2:tcp://localhost/mem:testdb username: sa jpa: hibernate: ddl-auto: create-drop show-sql: true generate-ddl: true defer-datasource-initialization: true sql: init: mode: always eureka: instance: instance-id: ${spring.application.name}:${spring.application.instance_id:${random.value}} client: register-with-eureka: true fetch-registry: true service-url: defaultZone: http://localhost:8761/eureka logging: level: com.example.catalogservice: DEBUG 추가한 내용은 spring.jpa.defer-datasource-initialization과 spring.sql.init.mode 설정입니다.
- 미해결Spring Cloud로 개발하는 마이크로서비스 애플리케이션(MSA)
Kafka Docker-compose기동시 connect는 어떻게 설정하나요?
안녕하세요!Kafka Docker-compose기동시 connect는 어떻게 설정하나요?강의내용에는 이 부분이 생략된 것 같아서 질문합니다!
- 미해결Spring Cloud로 개발하는 마이크로서비스 애플리케이션(MSA)
후속 강의 Webflux가 듣고 싶습니다.
강의를 듣다보니, Webflux 후속 강의를 준비하실 생각이 있다고 하셨는데, 계획이 있을까요?
- 미해결Spring Cloud로 개발하는 마이크로서비스 애플리케이션(MSA)
Spring Boot 최신 3.XX 버전 Security 설정 공유드립니다.
최신 버전 진행하시는 분들을 위해 공유드립니다.Spring Security Configuration 설정 내용이 변경되었습니다. WebSecurityConfigurerAdapter 클래스가 deprecated되었는데요. 해당 클래스를 상속 받아 config 메소드를 구현하는 대신 SecurityFilterChain을 반환하고 직접 Bean으로 등록하도록 설정 방법이 바뀌었습니다. package com.example.userservice.security; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import org.springframework.security.config.annotation.web.builders.HttpSecurity; import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity; import org.springframework.security.web.SecurityFilterChain; @Configuration @EnableWebSecurity public class WebSecurity { private static final String[] WHITE_LIST = { "/users/**", "/**" }; @Bean protected SecurityFilterChain config(HttpSecurity http) throws Exception { http.csrf().disable(); http.headers().frameOptions().disable(); http.authorizeHttpRequests(authorize -> authorize .requestMatchers(WHITE_LIST).permitAll()); return http.build(); } } 강의 내용을 진행하기 위해서 강의에 나온 설정을 위처럼 설정해보았는데요. 일단 이렇게 설정하면 강의를 진행하는데 문제 없을 것이니 참고 바랍니다~
- 미해결Spring Cloud로 개발하는 마이크로서비스 애플리케이션(MSA)
gradle
안녕하세요만약 9003번을 커맨드라인에서 gradle 명령어로 띄우려면 어떻게 해야하나요?
- 미해결Spring Cloud로 개발하는 마이크로서비스 애플리케이션(MSA)
kafka 설정 관련해서 올려주신 goolge drive 링크가 만료되었습니다
Error: Could not find or load main class org.apache.kafka.connect.cli.ConnectDistributedCaused by: java.lang.ClassNotFoundException: org.apache.kafka.connect.cli.ConnectDistributedkafka connect 설정도중 위의 에러가 해결되지 않아 통합 파일을 받으려했는데 페이지를 찾을 수 없다고 나옵니다.https://www.inflearn.com/questions/601451/windows-kafka-%EC%A0%95%EC%83%81-%EC%9E%91%EB%8F%99%ED%95%98%EB%8A%94-%EB%B2%84%EC%A0%84-%EC%A0%9C%EA%B3%B5%EB%AC%B8%EC%9D%98https://drive.google.com/file/d/1GDrBskzAE4Y_GojNeXhGeN2YeMFrpFe-/view?usp=sharing링크 공유 다시해주시면 감사하겠습니다.
- 미해결Spring Cloud로 개발하는 마이크로서비스 애플리케이션(MSA)
Order 서비스의 도메인
Order Service URL 주소에서IP:PORT/user/{user-id}/order 이렇게 주소를 주셨는데Restful API 에서 주문 도메인에 있는 정보를 유저 아이디 값으로 가져오고 싶을 때GET ip:port/order?user-id='' 로 가져와도 상관없을까요? 이게 API 디자인 가이드에 위배 되는 행위인지 궁금합니다.
- 미해결Spring Cloud로 개발하는 마이크로서비스 애플리케이션(MSA)
Actuator를 통해 앱을 재시작하지않고 DB 커넥션변경 가능할까요?
Actuator와 cloud bus라는 좋은 기능을 보면서 궁금증이 생겼습니다!이를 통해 자바 어플리케이션을 재시작하지않고 DB 커넥션변경 가능할까요??actuator로 db를 계속 변경 할 수 있으면 너무 좋을 것 같습니다!!