묻고 답해요
167만명의 커뮤니티!! 함께 토론해봐요.
인프런 TOP Writers
-
미해결실전! 스프링 부트와 JPA 활용1 - 웹 애플리케이션 개발
IllegalStateException
[질문 템플릿]1. 강의 내용과 관련된 질문인가요? (예)2. 인프런의 질문 게시판과 자주 하는 질문에 없는 내용인가요? (아니요)3. 질문 잘하기 메뉴얼을 읽어보셨나요? (예)[질문 내용]강의들으면서 코드를 따라쳐도 안되서 프로젝트 파일 삭제후 강의 자료에 있는 코드들을 복사해서 해도 계속 같은 오류가 나옵니다. 해결방법 알려주시면 감사하겠습니다!
-
미해결실전! 스프링 데이터 JPA
의존성 관련 질문
학습하는 분들께 도움이 되고, 더 좋은 답변을 드릴 수 있도록 질문전에 다음을 꼭 확인해주세요.1. 강의 내용과 관련된 질문을 남겨주세요.2. 인프런의 질문 게시판과 자주 하는 질문(링크)을 먼저 확인해주세요.(자주 하는 질문 링크: https://bit.ly/3fX6ygx)3. 질문 잘하기 메뉴얼(링크)을 먼저 읽어주세요.(질문 잘하기 메뉴얼 링크: https://bit.ly/2UfeqCG)질문 시에는 위 내용은 삭제하고 다음 내용을 남겨주세요.=========================================[질문 템플릿]1. 강의 내용과 관련된 질문인가요? (예/아니오)2. 인프런의 질문 게시판과 자주 하는 질문에 없는 내용인가요? (예/아니오)3. 질문 잘하기 메뉴얼을 읽어보셨나요? (예/아니오)[질문 내용]여기에 질문 내용을 남겨주세요. 의존성에 대해 갑자기 헷갈려서 총 4가지 질문드립니다.MemberService에 아래와 같은 메서드(Member findMemberById(Long id))가 있고 PostService(다른 Service 클래스)에서 memberId로 Member를 조회해야 할 일이 있습니다. 이 경우 아래 메서드를 이용하기 위해 PostService 클래스에서 private final MemberService memberService 형태로 멤버변수로 포함한다고 가정하겠습니다.(memberService.findMemberByMember(id) 로 이용하기위해)public Member findMemberById(Long id) { return memberRepository.findById(id) .orElseThrow(() -> new BusinessLogicException(MEMBER_NOT_FOUND)); } Q1) PostService에서 MemberService를 생성자 주입을 통해 받아서 이용할 경우 MemberService의 의존성(예를 들면 MemberRepository 등의 MemberService 클래스에서 사용하는 클래스들)까지 PostService에 포함되는 것일까요? Q2) 의존성이라는게 단순히 생성자 주입으로 받았던 멤버 클래스들 뿐 아니라 내부 메소드에서 매개변수로 받은 클래스가 있다면 이 또한 의존성인가요?(import 로 포함된 클래스들을 모두 의존클래스로 보면 될지, 아니면 내부에서 사용하는 모든 객체를 의존성으로 보면될지 >> 같은 패키지의 경우 import 안하는걸 고려했을때 내부에서 객체로 이용하지만 같은 패키지라 import 안되는걸 고려) Q3-1) Q1의 답변에서 MemberService의 의존성까지 PostService에 포함되는 거라면 PostService에서 Member를 조회하기 위해서는 memberService.findMemberById(id) 로 조회하기 보단 MemberRepository를 주입받아서 memberRepository.findById(id).orElseThrow(() -> new BusinessLogicException(MEMBER_NOT_FOUND)); 형태로 변경하는게 맞을지? Q3-2) Q1의 답변에서 MemberService의 의존성까지 PostService에 포함되는게 아니라면 PostService에서 MemberService가 아닌 MemberRepository로 조회하는게 맞을지? Member 조회가 여러곳에서 사용되고 Member findMemberById(Long id) 메소드의 내용이 여러곳에서 중복되는 걸 생각했을때처음에는 단순히 member 조회가 여러곳에서 일어나고 공통된 내용이 반복되어 MemberService의 findMemberById 로 묶어서 사용하는게 맞다고 생각했는데 의문이 들었고 예전에 의존성은 최대한 줄이라고 하셨던게 생각나서 질문드립니다.
-
해결됨스프링부트 JUnit 테스트 - 시큐리티를 활용한 Bank 애플리케이션
변경된 시큐리티의 filterChain에서 and() 메서드 사용은 권장하지 않나요?
기존 상속 받아서 사용하던 것 처럼 변경된 filterChain에서도 and() 메서드를 사용해서 옵션들을 빌더 연결 패턴 처럼 사용할 수 있던데 변경된 시큐리티에선 권장하지 않는 방법인지, 아니면 가독성 때문인지 궁금합니다! @Bean public SecurityFilterChain filterChain(HttpSecurity http) throws Exception { log.debug("디버그: filterChain 빈 등록됨"); http.headers().frameOptions().disable() .and() .csrf().disable() .cors().configurationSource(configurationSource()) .and() .sessionManagement().sessionCreationPolicy(SessionCreationPolicy.STATELESS) .and() .formLogin().disable() .httpBasic().disable() .apply(new CustomSecurityFilterManager()) .and() .exceptionHandling().authenticationEntryPoint((request, response, authException) -> { CustomResponseUtil.fail(response, "로그인을 진행해 주세요", HttpStatus.UNAUTHORIZED); }) .and() .exceptionHandling().accessDeniedHandler((request, response, e) -> { CustomResponseUtil.fail(response, "권한이 없습니다", HttpStatus.FORBIDDEN); }) .and() .authorizeRequests() .antMatchers("/api/s/**").authenticated() .antMatchers("/api/admin/**").hasRole("" + UserEnum.ADMIN) .anyRequest().permitAll(); return http.build(); }
-
해결됨스프링 입문 - 코드로 배우는 스프링 부트, 웹 MVC, DB 접근 기술
애플리케이션 런 했을때 에러 발생
학습하는 분들께 도움이 되고, 더 좋은 답변을 드릴 수 있도록 질문전에 다음을 꼭 확인해주세요.1. 강의 내용과 관련된 질문을 남겨주세요.2. 인프런의 질문 게시판과 자주 하는 질문(링크)을 먼저 확인해주세요.(자주 하는 질문 링크: https://bit.ly/3fX6ygx)3. 질문 잘하기 메뉴얼(링크)을 먼저 읽어주세요.(질문 잘하기 메뉴얼 링크: https://bit.ly/2UfeqCG)질문 시에는 위 내용은 삭제하고 다음 내용을 남겨주세요.=========================================[질문 템플릿]1. 강의 내용과 관련된 질문인가요? (예/아니오)2. 인프런의 질문 게시판과 자주 하는 질문에 없는 내용인가요? (예/아니오)3. 질문 잘하기 메뉴얼을 읽어보셨나요? (예/아니오)[질문 내용]여기에 질문 내용을 남겨주세요.안녕하세요 vs코드에서 자바 배우려고 intellj(무료버전)를 설치 후 강의를 따라가고 있습니다. 그런데 HelloSpringApplication을 런 했을때 3가지 에러가 발생하는데 핸들링 부탁드립니다.크게는 이 3가지가 나오고, 이건 첫번째 에러인데 해결하지 못했습니다 ㅠㅠ답변 부탁드립니다.
-
해결됨토비의 스프링 부트 - 이해와 원리
회사 비지니스 공통업무처리 관련 유용한 라이브러리 들이 있는지 여쭤봅니다
안녕하세요 토비님~이번에도 강의 내용과 상관 없는 질문 드립니다회사에서 타임리프 + JPA + 마이바티스 + 스프링/스프링부트 + 오라클 환경에서 개발하고 있습니다 MVC CRUD, API 송수신, 특이업무를 제외하고는 보통 회사에서 일어나는 공통업무는 아래와 같은 부분이 있다고 생각 합니다*.엑셀다운*.엑셀업로드*.이메일전송(첨부파일포함)*.PDF다운*.FAX전송*.출력 다른 분들이 먼저 개발해 놓은 소스를 참고해 가며개발 수정 운영을 하고 있는데요 제가 느끼기에는 뭔가 불필요한 소스 코드가 많고 긴 건 아닐까?..누군가 잘 만들어 놓은 라이브러리 메서드에 파라미터만 담아주고호출 하면 되진 않을까 생각이 들었습니다 혹시, 아래와 같은 공통 업무 사항들에 대해서 스프링 진영에서 Util 성격으로 잘 만들어 미리 만들어 놓은 좋은 라이브러리가 있지는 않 을까 생각이 듭니다 (엑셀업로드,다운로드/이메일송수신/PDF/FAX/출력 .. )회사마다 환경이나 요구 상황에 따라서 다르겠지만, 토비님은 이런 공통 비지니스 업무 관련 엑셀업로드,다운로드/이메일송수신/PDF/FAX/출력 관련 공통 비지니스 업무 관련해서 스프링 진영에서 혹시 이미 만들어 놓은 라이브러리 의존 관계를 추가해서사용하고 계시는 부분이 있나 여쭤봅니다 만약 사용하고 계신다면 어떠 어떠한 것들이 있는지 소개 부탁 드립니다 급한 질문 아닙니 시간 나 실 때알려주시면 감사하겠습니다. 수고하세요.--█●●--------------------------------------------#엑셀#이메일#PDF#FAX#출력#스프링#스프링부트#부트#spring #sping-boot#springboot#토비#공통#라이브러리--█●●--------------------------------------------
-
미해결스프링 시큐리티 OAuth2
Spring Authorization Server 1.0.1 state 문의
authorization_code grantType 으로 인가를 진행한다고 가 정하였을때 authorization_code 발급 요청에서 사용한 state 와 token 발급 요청해서 사용하는 state가 다르면 token 발급이 실패 해야 하는데 성공하고 있어서 분석해보니 oauth2_authorization 테이블의 state 필드가 null 로 저장되고 있습니다. JdbcOAuth2AuthorizationService를 사용하지 않고 커스텀한 구현체를 만들어서 사용하고 있는것이 원인일 수 있어 디버깅 해보니 OAuth2Authorization 의 소스를 분석해보면 state 가 포함되고 있지 않아서 저장이 안되고 있는데 아직 Spring Authorization Server는 state 가 구현되지 않은 걸까요? 추가로 소스를 분석해보니 nonce 도 아직 구현되지 않은거 같습니다.Spring Authorization Server 1.0.1 의 OAuth2Authorization 소스package org.springframework.security.oauth2.server.authorization; import java.io.Serializable; import java.time.Instant; import java.util.Collections; import java.util.HashMap; import java.util.HashSet; import java.util.Map; import java.util.Objects; import java.util.Set; import java.util.UUID; import java.util.function.Consumer; import org.springframework.lang.Nullable; import org.springframework.security.oauth2.core.AuthorizationGrantType; import org.springframework.security.oauth2.core.OAuth2AccessToken; import org.springframework.security.oauth2.core.OAuth2RefreshToken; import org.springframework.security.oauth2.core.OAuth2Token; import org.springframework.security.oauth2.server.authorization.client.RegisteredClient; import org.springframework.security.oauth2.server.authorization.util.SpringAuthorizationServerVersion; import org.springframework.util.Assert; import org.springframework.util.CollectionUtils; import org.springframework.util.StringUtils; /** * A representation of an OAuth 2.0 Authorization, which holds state related to the authorization granted * to a {@link #getRegisteredClientId() client}, by the {@link #getPrincipalName() resource owner} * or itself in the case of the {@code client_credentials} grant type. * * @author Joe Grandja * @author Krisztian Toth * @since 0.0.1 * @see RegisteredClient * @see AuthorizationGrantType * @see OAuth2Token * @see OAuth2AccessToken * @see OAuth2RefreshToken */ public class OAuth2Authorization implements Serializable { private static final long serialVersionUID = SpringAuthorizationServerVersion.SERIAL_VERSION_UID; private String id; private String registeredClientId; private String principalName; private AuthorizationGrantType authorizationGrantType; private Set<String> authorizedScopes; private Map<Class<? extends OAuth2Token>, Token<?>> tokens; private Map<String, Object> attributes; protected OAuth2Authorization() { } /** * Returns the identifier for the authorization. * * @return the identifier for the authorization */ public String getId() { return this.id; } /** * Returns the identifier for the {@link RegisteredClient#getId() registered client}. * * @return the {@link RegisteredClient#getId()} */ public String getRegisteredClientId() { return this.registeredClientId; } /** * Returns the {@code Principal} name of the resource owner (or client). * * @return the {@code Principal} name of the resource owner (or client) */ public String getPrincipalName() { return this.principalName; } /** * Returns the {@link AuthorizationGrantType authorization grant type} used for the authorization. * * @return the {@link AuthorizationGrantType} used for the authorization */ public AuthorizationGrantType getAuthorizationGrantType() { return this.authorizationGrantType; } /** * Returns the authorized scope(s). * * @return the {@code Set} of authorized scope(s) * @since 0.4.0 */ public Set<String> getAuthorizedScopes() { return this.authorizedScopes; } /** * Returns the {@link Token} of type {@link OAuth2AccessToken}. * * @return the {@link Token} of type {@link OAuth2AccessToken} */ public Token<OAuth2AccessToken> getAccessToken() { return getToken(OAuth2AccessToken.class); } /** * Returns the {@link Token} of type {@link OAuth2RefreshToken}. * * @return the {@link Token} of type {@link OAuth2RefreshToken}, or {@code null} if not available */ @Nullable public Token<OAuth2RefreshToken> getRefreshToken() { return getToken(OAuth2RefreshToken.class); } /** * Returns the {@link Token} of type {@code tokenType}. * * @param tokenType the token type * @param <T> the type of the token * @return the {@link Token}, or {@code null} if not available */ @Nullable @SuppressWarnings("unchecked") public <T extends OAuth2Token> Token<T> getToken(Class<T> tokenType) { Assert.notNull(tokenType, "tokenType cannot be null"); Token<?> token = this.tokens.get(tokenType); return token != null ? (Token<T>) token : null; } /** * Returns the {@link Token} matching the {@code tokenValue}. * * @param tokenValue the token value * @param <T> the type of the token * @return the {@link Token}, or {@code null} if not available */ @Nullable @SuppressWarnings("unchecked") public <T extends OAuth2Token> Token<T> getToken(String tokenValue) { Assert.hasText(tokenValue, "tokenValue cannot be empty"); for (Token<?> token : this.tokens.values()) { if (token.getToken().getTokenValue().equals(tokenValue)) { return (Token<T>) token; } } return null; } /** * Returns the attribute(s) associated to the authorization. * * @return a {@code Map} of the attribute(s) */ public Map<String, Object> getAttributes() { return this.attributes; } /** * Returns the value of an attribute associated to the authorization. * * @param name the name of the attribute * @param <T> the type of the attribute * @return the value of an attribute associated to the authorization, or {@code null} if not available */ @Nullable @SuppressWarnings("unchecked") public <T> T getAttribute(String name) { Assert.hasText(name, "name cannot be empty"); return (T) this.attributes.get(name); } @Override public boolean equals(Object obj) { if (this == obj) { return true; } if (obj == null || getClass() != obj.getClass()) { return false; } OAuth2Authorization that = (OAuth2Authorization) obj; return Objects.equals(this.id, that.id) && Objects.equals(this.registeredClientId, that.registeredClientId) && Objects.equals(this.principalName, that.principalName) && Objects.equals(this.authorizationGrantType, that.authorizationGrantType) && Objects.equals(this.authorizedScopes, that.authorizedScopes) && Objects.equals(this.tokens, that.tokens) && Objects.equals(this.attributes, that.attributes); } @Override public int hashCode() { return Objects.hash(this.id, this.registeredClientId, this.principalName, this.authorizationGrantType, this.authorizedScopes, this.tokens, this.attributes); } /** * Returns a new {@link Builder}, initialized with the provided {@link RegisteredClient#getId()}. * * @param registeredClient the {@link RegisteredClient} * @return the {@link Builder} */ public static Builder withRegisteredClient(RegisteredClient registeredClient) { Assert.notNull(registeredClient, "registeredClient cannot be null"); return new Builder(registeredClient.getId()); } /** * Returns a new {@link Builder}, initialized with the values from the provided {@code OAuth2Authorization}. * * @param authorization the {@code OAuth2Authorization} used for initializing the {@link Builder} * @return the {@link Builder} */ public static Builder from(OAuth2Authorization authorization) { Assert.notNull(authorization, "authorization cannot be null"); return new Builder(authorization.getRegisteredClientId()) .id(authorization.getId()) .principalName(authorization.getPrincipalName()) .authorizationGrantType(authorization.getAuthorizationGrantType()) .authorizedScopes(authorization.getAuthorizedScopes()) .tokens(authorization.tokens) .attributes(attrs -> attrs.putAll(authorization.getAttributes())); } /** * A holder of an OAuth 2.0 Token and it's associated metadata. * * @author Joe Grandja * @since 0.1.0 */ public static class Token<T extends OAuth2Token> implements Serializable { private static final long serialVersionUID = SpringAuthorizationServerVersion.SERIAL_VERSION_UID; protected static final String TOKEN_METADATA_NAMESPACE = "metadata.token."; /** * The name of the metadata that indicates if the token has been invalidated. */ public static final String INVALIDATED_METADATA_NAME = TOKEN_METADATA_NAMESPACE.concat("invalidated"); /** * The name of the metadata used for the claims of the token. */ public static final String CLAIMS_METADATA_NAME = TOKEN_METADATA_NAMESPACE.concat("claims"); private final T token; private final Map<String, Object> metadata; protected Token(T token) { this(token, defaultMetadata()); } protected Token(T token, Map<String, Object> metadata) { this.token = token; this.metadata = Collections.unmodifiableMap(metadata); } /** * Returns the token of type {@link OAuth2Token}. * * @return the token of type {@link OAuth2Token} */ public T getToken() { return this.token; } /** * Returns {@code true} if the token has been invalidated (e.g. revoked). * The default is {@code false}. * * @return {@code true} if the token has been invalidated, {@code false} otherwise */ public boolean isInvalidated() { return Boolean.TRUE.equals(getMetadata(INVALIDATED_METADATA_NAME)); } /** * Returns {@code true} if the token has expired. * * @return {@code true} if the token has expired, {@code false} otherwise */ public boolean isExpired() { return getToken().getExpiresAt() != null && Instant.now().isAfter(getToken().getExpiresAt()); } /** * Returns {@code true} if the token is before the time it can be used. * * @return {@code true} if the token is before the time it can be used, {@code false} otherwise */ public boolean isBeforeUse() { Instant notBefore = null; if (!CollectionUtils.isEmpty(getClaims())) { notBefore = (Instant) getClaims().get("nbf"); } return notBefore != null && Instant.now().isBefore(notBefore); } /** * Returns {@code true} if the token is currently active. * * @return {@code true} if the token is currently active, {@code false} otherwise */ public boolean isActive() { return !isInvalidated() && !isExpired() && !isBeforeUse(); } /** * Returns the claims associated to the token. * * @return a {@code Map} of the claims, or {@code null} if not available */ @Nullable public Map<String, Object> getClaims() { return getMetadata(CLAIMS_METADATA_NAME); } /** * Returns the value of the metadata associated to the token. * * @param name the name of the metadata * @param <V> the value type of the metadata * @return the value of the metadata, or {@code null} if not available */ @Nullable @SuppressWarnings("unchecked") public <V> V getMetadata(String name) { Assert.hasText(name, "name cannot be empty"); return (V) this.metadata.get(name); } /** * Returns the metadata associated to the token. * * @return a {@code Map} of the metadata */ public Map<String, Object> getMetadata() { return this.metadata; } protected static Map<String, Object> defaultMetadata() { Map<String, Object> metadata = new HashMap<>(); metadata.put(INVALIDATED_METADATA_NAME, false); return metadata; } @Override public boolean equals(Object obj) { if (this == obj) { return true; } if (obj == null || getClass() != obj.getClass()) { return false; } Token<?> that = (Token<?>) obj; return Objects.equals(this.token, that.token) && Objects.equals(this.metadata, that.metadata); } @Override public int hashCode() { return Objects.hash(this.token, this.metadata); } } /** * A builder for {@link OAuth2Authorization}. */ public static class Builder implements Serializable { private static final long serialVersionUID = SpringAuthorizationServerVersion.SERIAL_VERSION_UID; private String id; private final String registeredClientId; private String principalName; private AuthorizationGrantType authorizationGrantType; private Set<String> authorizedScopes; private Map<Class<? extends OAuth2Token>, Token<?>> tokens = new HashMap<>(); private final Map<String, Object> attributes = new HashMap<>(); protected Builder(String registeredClientId) { this.registeredClientId = registeredClientId; } /** * Sets the identifier for the authorization. * * @param id the identifier for the authorization * @return the {@link Builder} */ public Builder id(String id) { this.id = id; return this; } /** * Sets the {@code Principal} name of the resource owner (or client). * * @param principalName the {@code Principal} name of the resource owner (or client) * @return the {@link Builder} */ public Builder principalName(String principalName) { this.principalName = principalName; return this; } /** * Sets the {@link AuthorizationGrantType authorization grant type} used for the authorization. * * @param authorizationGrantType the {@link AuthorizationGrantType} * @return the {@link Builder} */ public Builder authorizationGrantType(AuthorizationGrantType authorizationGrantType) { this.authorizationGrantType = authorizationGrantType; return this; } /** * Sets the authorized scope(s). * * @param authorizedScopes the {@code Set} of authorized scope(s) * @return the {@link Builder} * @since 0.4.0 */ public Builder authorizedScopes(Set<String> authorizedScopes) { this.authorizedScopes = authorizedScopes; return this; } /** * Sets the {@link OAuth2AccessToken access token}. * * @param accessToken the {@link OAuth2AccessToken} * @return the {@link Builder} */ public Builder accessToken(OAuth2AccessToken accessToken) { return token(accessToken); } /** * Sets the {@link OAuth2RefreshToken refresh token}. * * @param refreshToken the {@link OAuth2RefreshToken} * @return the {@link Builder} */ public Builder refreshToken(OAuth2RefreshToken refreshToken) { return token(refreshToken); } /** * Sets the {@link OAuth2Token token}. * * @param token the token * @param <T> the type of the token * @return the {@link Builder} */ public <T extends OAuth2Token> Builder token(T token) { return token(token, (metadata) -> {}); } /** * Sets the {@link OAuth2Token token} and associated metadata. * * @param token the token * @param metadataConsumer a {@code Consumer} of the metadata {@code Map} * @param <T> the type of the token * @return the {@link Builder} */ public <T extends OAuth2Token> Builder token(T token, Consumer<Map<String, Object>> metadataConsumer) { Assert.notNull(token, "token cannot be null"); Map<String, Object> metadata = Token.defaultMetadata(); Token<?> existingToken = this.tokens.get(token.getClass()); if (existingToken != null) { metadata.putAll(existingToken.getMetadata()); } metadataConsumer.accept(metadata); Class<? extends OAuth2Token> tokenClass = token.getClass(); this.tokens.put(tokenClass, new Token<>(token, metadata)); return this; } protected final Builder tokens(Map<Class<? extends OAuth2Token>, Token<?>> tokens) { this.tokens = new HashMap<>(tokens); return this; } /** * Adds an attribute associated to the authorization. * * @param name the name of the attribute * @param value the value of the attribute * @return the {@link Builder} */ public Builder attribute(String name, Object value) { Assert.hasText(name, "name cannot be empty"); Assert.notNull(value, "value cannot be null"); this.attributes.put(name, value); return this; } /** * A {@code Consumer} of the attributes {@code Map} * allowing the ability to add, replace, or remove. * * @param attributesConsumer a {@link Consumer} of the attributes {@code Map} * @return the {@link Builder} */ public Builder attributes(Consumer<Map<String, Object>> attributesConsumer) { attributesConsumer.accept(this.attributes); return this; } /** * Builds a new {@link OAuth2Authorization}. * * @return the {@link OAuth2Authorization} */ public OAuth2Authorization build() { Assert.hasText(this.principalName, "principalName cannot be empty"); Assert.notNull(this.authorizationGrantType, "authorizationGrantType cannot be null"); OAuth2Authorization authorization = new OAuth2Authorization(); if (!StringUtils.hasText(this.id)) { this.id = UUID.randomUUID().toString(); } authorization.id = this.id; authorization.registeredClientId = this.registeredClientId; authorization.principalName = this.principalName; authorization.authorizationGrantType = this.authorizationGrantType; authorization.authorizedScopes = Collections.unmodifiableSet( !CollectionUtils.isEmpty(this.authorizedScopes) ? new HashSet<>(this.authorizedScopes) : new HashSet<>() ); authorization.tokens = Collections.unmodifiableMap(this.tokens); authorization.attributes = Collections.unmodifiableMap(this.attributes); return authorization; } } }
-
미해결실전! 스프링 부트와 JPA 활용1 - 웹 애플리케이션 개발
test파일의 application.yml 내용 없는경우
test디렉토리의 resouces패키지를 만들고, 그 안에 application.yml 을 생성해서 인메모리모드를 보여주셨습니다.아무 코드가 없는 백지상태여도 인메모리모드로 돌아간다고 하셨는데요, 그래도 내용만 빌 뿐이지, 인메모리 환경을 위해서는 꼭 application.yml파일이 test디렉토리의 해당경로에 존재해야하는게 맞나요?
-
미해결스프링 입문 - 코드로 배우는 스프링 부트, 웹 MVC, DB 접근 기술
회원조회가 되지 않습니다.
학습하는 분들께 도움이 되고, 더 좋은 답변을 드릴 수 있도록 질문전에 다음을 꼭 확인해주세요.1. 강의 내용과 관련된 질문을 남겨주세요.2. 인프런의 질문 게시판과 자주 하는 질문(링크)을 먼저 확인해주세요.(자주 하는 질문 링크: https://bit.ly/3fX6ygx)3. 질문 잘하기 메뉴얼(링크)을 먼저 읽어주세요.(질문 잘하기 메뉴얼 링크: https://bit.ly/2UfeqCG)질문 시에는 위 내용은 삭제하고 다음 내용을 남겨주세요.=========================================[질문 템플릿]1. 강의 내용과 관련된 질문인가요? (예/아니오)2. 인프런의 질문 게시판과 자주 하는 질문에 없는 내용인가요? (예/아니오)3. 질문 잘하기 메뉴얼을 읽어보셨나요? (예/아니오)[질문 내용]회원등록을 하지 않았으 때 회원 조회를 하게되면 # 이름은 뜨게 되는데 회원등록을 하고 난 후 회원조회를 하게되면 오류가 뜹니다. 도와주시면 감사하겠습니다!https://github.com/JongchanJeon/starter_Spring 감사합니다.
-
미해결토비의 스프링 부트 - 이해와 원리
5:40분초 쯤에... 프로퍼티클래스의 분리 강의에서
@Bean @ConditionalOnMissingBean public ServletWebServerFactory jettyServletWebServerFactory(ServerProperties serverProperties){} 이부분에 ServerProperties 을 따로 주입을 안받아도 되나요..? 빈으로 띄워서 그런건가..?매개변수에 딱 저렇게 누가 넣어주는건가요..?@Autowired없이..? 헷갈리네요 ㅠㅠㅠ
-
미해결스프링 입문 - 코드로 배우는 스프링 부트, 웹 MVC, DB 접근 기술
localhost:8080/hello에 에러가 계속 생깁니다.
학습하는 분들께 도움이 되고, 더 좋은 답변을 드릴 수 있도록 질문전에 다음을 꼭 확인해주세요.1. 강의 내용과 관련된 질문을 남겨주세요.2. 인프런의 질문 게시판과 자주 하는 질문(링크)을 먼저 확인해주세요.(자주 하는 질문 링크: https://bit.ly/3fX6ygx)3. 질문 잘하기 메뉴얼(링크)을 먼저 읽어주세요.(질문 잘하기 메뉴얼 링크: https://bit.ly/2UfeqCG)질문 시에는 위 내용은 삭제하고 다음 내용을 남겨주세요.=========================================[질문 템플릿]1. 강의 내용과 관련된 질문인가요? (예/아니오)2. 인프런의 질문 게시판과 자주 하는 질문에 없는 내용인가요? (예/아니오)3. 질문 잘하기 메뉴얼을 읽어보셨나요? (예/아니오)[질문 내용]강의에 나온 코드를 그대로 복사 붙여 넣기하여 작성한 코드임에도 불구하고 계속 localhost:8080/hello에서 이 오류가 발생합니다.몇번을 봐도 문제는 없는거 같은데 왜 이럴까요?
-
해결됨실전! 스프링 부트와 JPA 활용2 - API 개발과 성능 최적화
415 오류가 자꾸 발생합니다
학습하는 분들께 도움이 되고, 더 좋은 답변을 드릴 수 있도록 질문전에 다음을 꼭 확인해주세요.1. 강의 내용과 관련된 질문을 남겨주세요.2. 인프런의 질문 게시판과 자주 하는 질문(링크)을 먼저 확인해주세요.(자주 하는 질문 링크: https://bit.ly/3fX6ygx)3. 질문 잘하기 메뉴얼(링크)을 먼저 읽어주세요.(질문 잘하기 메뉴얼 링크: https://bit.ly/2UfeqCG)질문 시에는 위 내용은 삭제하고 다음 내용을 남겨주세요.=========================================[질문 템플릿]1. 강의 내용과 관련된 질문인가요? (예/아니오)2. 인프런의 질문 게시판과 자주 하는 질문에 없는 내용인가요? (예/아니오)3. 질문 잘하기 메뉴얼을 읽어보셨나요? (예/아니오)[질문 내용] Postman에서 send를 해도 아래와같은 오류가 발생하며 실행되지 않습니다. Headers에서 Context-Type이 분명 application/json인데 뭐가 문제일까요 x-www-form-urlencoded로 변경하고 Context-Type도 이와 같이 변경한 후에 @RequestBody를 지우면 데이터가 잘 들어오는 것을 확인할 수 있었습니다. 2023-03-29 19:41:13.746 WARN 13008 --- [nio-8080-exec-1] .w.s.m.s.DefaultHandlerExceptionResolver : Resolved [org.springframework.web.HttpMediaTypeNotSupportedException: Content type 'application/json;charset=UTF-8' not supported]2023-03-29 19:41:13.780 WARN 13008 --- [nio-8080-exec-1] .m.m.a.ExceptionHandlerExceptionResolver : Resolved [org.springframework.web.HttpMediaTypeNotAcceptableException: Could not find acceptable representation]아래는 제 코드와 헤더입니다.
-
미해결실전! 스프링 부트와 JPA 활용2 - API 개발과 성능 최적화
컬럼명 앞에 테이블명 붙이는 방법
[질문 템플릿]1. 강의 내용과 관련된 질문인가요? (예)2. 인프런의 질문 게시판과 자주 하는 질문에 없는 내용인가요? (예)3. 질문 잘하기 메뉴얼을 읽어보셨나요? (예)[질문 내용]테이블 명이 member이고 컬럼명이 name이면 테이블이 생성될때 컬럼명이 member_name으로 모든 컬럼 앞에 테이블명이 자동으로 생성되는 어노테이션을 들었던 기억이 있는데 어떤 어노테이션이었는지 기억이 잘 안납니다.. 도와주실 수 있을까요?
-
미해결실전! 스프링 부트와 JPA 활용1 - 웹 애플리케이션 개발
안녕하세요
학습하는 분들께 도움이 되고, 더 좋은 답변을 드릴 수 있도록 질문전에 다음을 꼭 확인해주세요.1. 강의 내용과 관련된 질문을 남겨주세요.2. 인프런의 질문 게시판과 자주 하는 질문(링크)을 먼저 확인해주세요.(자주 하는 질문 링크: https://bit.ly/3fX6ygx)3. 질문 잘하기 메뉴얼(링크)을 먼저 읽어주세요.(질문 잘하기 메뉴얼 링크: https://bit.ly/2UfeqCG)질문 시에는 위 내용은 삭제하고 다음 내용을 남겨주세요.=========================================[질문 템플릿]1. 강의 내용과 관련된 질문인가요? (예/아니오)2. 인프런의 질문 게시판과 자주 하는 질문에 없는 내용인가요? (예/아니오)3. 질문 잘하기 메뉴얼을 읽어보셨나요? (예/아니오)[질문 내용]11분 50초 쯤 요즘 세션 객체를 안쓴다고 하셨는데 그럼 토큰으로 인증을 주로 하는 건가요?
-
미해결실전! 스프링 부트와 JPA 활용1 - 웹 애플리케이션 개발
MemberRepository 터미널 세팅 오류
학습하는 분들께 도움이 되고, 더 좋은 답변을 드릴 수 있도록 질문전에 다음을 꼭 확인해주세요.1. 강의 내용과 관련된 질문을 남겨주세요.2. 인프런의 질문 게시판과 자주 하는 질문(링크)을 먼저 확인해주세요.(자주 하는 질문 링크: https://bit.ly/3fX6ygx)3. 질문 잘하기 메뉴얼(링크)을 먼저 읽어주세요.(질문 잘하기 메뉴얼 링크: https://bit.ly/2UfeqCG)질문 시에는 위 내용은 삭제하고 다음 내용을 남겨주세요.=========================================[질문 템플릿]1. 강의 내용과 관련된 질문인가요? (예/아니오)2. 인프런의 질문 게시판과 자주 하는 질문에 없는 내용인가요? (예/아니오)3. 질문 잘하기 메뉴얼을 읽어보셨나요? (예/아니오)[질문 내용]➜ libs java -jar jpashop-0.0.1-SNAPSHOT.jar . ____ _ /\\ / ___'_ __ (_)_ _ \ \ \ \( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \ \\/ ___)| |_)| | | | | || (_| | ) ) ) ) ' |____| .__|_| |_|_| |_\__, | / / / / =========|_|==============|___/=/_/_/_/ :: Spring Boot :: (v2.7.10)2023-03-29 10:00:16.420 INFO [,,] 33389 --- [ main] jpabook.jpashop.JpashopApplication : Starting JpashopApplication using Java 17.0.6 on yunsang-yeon-ui-MacBookAir.local with PID 33389 (/Users/sangyeon/Desktop/study/jpashop/build/libs/jpashop-0.0.1-SNAPSHOT.jar started by sangyeon in /Users/sangyeon/Desktop/study/jpashop/build/libs)2023-03-29 10:00:16.422 INFO [,,] 33389 --- [ main] jpabook.jpashop.JpashopApplication : No active profile set, falling back to 1 default profile: "default"2023-03-29 10:00:17.075 INFO [,,] 33389 --- [ main] o.s.cloud.context.scope.GenericScope : BeanFactory id=7e250d03-eb6b-3405-9b07-0ce9cd1e93022023-03-29 10:00:17.575 INFO [,,] 33389 --- [ main] o.s.b.w.embedded.tomcat.TomcatWebServer : Tomcat initialized with port(s): 8080 (http)2023-03-29 10:00:17.583 INFO [,,] 33389 --- [ main] o.apache.catalina.core.StandardService : Starting service [Tomcat]2023-03-29 10:00:17.583 INFO [,,] 33389 --- [ main] org.apache.catalina.core.StandardEngine : Starting Servlet engine: [Apache Tomcat/9.0.73]2023-03-29 10:00:17.641 INFO [,,] 33389 --- [ main] o.a.c.c.C.[Tomcat].[localhost].[/] : Initializing Spring embedded WebApplicationContext2023-03-29 10:00:17.642 INFO [,,] 33389 --- [ main] w.s.c.ServletWebServerApplicationContext : Root WebApplicationContext: initialization completed in 1180 ms2023-03-29 10:00:18.403 INFO [,,] 33389 --- [ main] o.s.b.w.embedded.tomcat.TomcatWebServer : Tomcat started on port(s): 8080 (http) with context path ''2023-03-29 10:00:18.420 INFO [,,] 33389 --- [ main] jpabook.jpashop.JpashopApplication : Started JpashopApplication in 2.308 seconds (JVM running for 2.591)2023-03-29 10:00:27.868 INFO [,06eafb76d211bbc3,06eafb76d211bbc3] 33389 --- [nio-8080-exec-1] o.a.c.c.C.[Tomcat].[localhost].[/] : Initializing Spring DispatcherServlet 'dispatcherServlet'2023-03-29 10:00:27.868 INFO [,06eafb76d211bbc3,06eafb76d211bbc3] 33389 --- [nio-8080-exec-1] o.s.web.servlet.DispatcherServlet : Initializing Servlet 'dispatcherServlet'2023-03-29 10:00:27.869 INFO [,06eafb76d211bbc3,06eafb76d211bbc3] 33389 --- [nio-8080-exec-1] o.s.web.servlet.DispatcherServlet : Completed initialization in 1 ms 이렇게 나오고 local host 8080에 들어가니Whitelabel Error PageThis application has no explicit mapping for /error, so you are seeing this as a fallback.Wed Mar 29 10:00:27 KST 2023There was an unexpected error (type=Not Found, status=404).이렇게 뜹니다.
-
해결됨스프링부트 JUnit 테스트 - 시큐리티를 활용한 Bank 애플리케이션
이클립스 VS 비주얼스튜디오 장 단점 알려주세요~
안녕하세요 강사님 ~현재 저는 이클립스 사용해서 개발중 입니다회사에 일부 신입개발자나, 젊은 분들은 비주얼스튜디오코드를 사용중이더라구요저는 아직 설치는 아직 해보지 않았지만, 처음 설정 잡기가 많이 까다롭다고 하더라구요 강사님 개발 경력이 많으시니, 최주호 강사님이 생각 하시는 이클립스에서 -> 비주얼스튜디오 로 갈아 탄다면 어떤 이점이 있고, 이런 부분은 불편해서 감안 해야 한다 설명 해주셨으면 좋겠습니다 ( 참고로 html, css, jquery, javascript 뒷단 java, sql 모든 부분 개발 유지 보수 하고 있습니다 ) 급한 부분 아니니 한가하게 시간 나실 때 답변 주세요..계속 좋은 강의 많이 올려주셨으면 좋겠습니다감사합니다. 좋은 하루 보네 세요~ #장단#장단점#비교#eclipse#비주얼스튜디오코드#visual-studio-code#visual#studio#code#비주얼#스튜디오#코드
-
해결됨스프링 부트 - 핵심 원리와 활용
예제 코드 작성시 왜 생성자를 @Autowired 안 쓰고 명시 해서 만드시나요?
강사님 안녕하세요~스프링부트 강의 잘 듣고 있습니다.. 자동구성 > 예제만들기 동영상 중 @Repository 만들 때 왜 public MemberRepository(JdbcTemplate templage)주입받게 하나 @Autowired 로하면 안되나요? ( 불필요하게 코드도 만들고 길어진다고 생각이 들어서요... )테스트 코드 작성 인지 때문 인지.. 강사님의 강의 대부분의 동영상에서는 생성자를 꼭 만드시더라구요오토와이어드 안 쓰구요 제가 기본 개념이 안되어서 이런 질문을 드리는 건지 죄송하고 부끄럽지만 질문 드립니다 #스프링#스프링부트#spring#boot#spring-boot#Autowired#생성자#왜#주입#받게#하나
-
미해결실전! 스프링 부트와 JPA 활용1 - 웹 애플리케이션 개발
testMember 실행 오류
강의를 따라하어 testMember를 실행해서 h2 db에서 member 테이블이 생성되고 memberA 까지 추가된것을 확인한 후에 코드를 수정하지 않고 한번 더 돌렸는데 그때 부터 계속 저런 오류가 발생합니다.혹, DB에 이미 테이블이 생성되어서 그런것인가요? 아니면 다른 문제가 있는건가요?
-
해결됨실전! 스프링 부트와 JPA 활용2 - API 개발과 성능 최적화
distinct를 적용하지 않았을 때의 결과 관련
강의를 중간에 distinct를 적용하지 않으면 포스트맨에서 결과가 중복되게 나오고, 쿼리도 inner join으로 되어야 하는데 이상합니다ㅜ코드가 모두 동일한데, 콘솔에 찍어봐도 4건이 아닌 2건 밖에 조회가 되지 않고 결과도 2건으로 나옵니다..또한, 강의에서는 inner join이 나가는데 제 코드는 join이 나갑니다..뭐가 문제일까요?
-
해결됨실전! 코틀린과 스프링 부트로 도서관리 애플리케이션 개발하기 (Java 프로젝트 리팩토링)
Calculator 클래스에서 참조값이 다르다고 에러가 발생합니다.
안녕하세요. 강의 잘 듣고 있습니다! 7:28 분쯤에 테스트코드를 실행하는데Exception in thread "main" java.lang.IllegalStateException at com.group.libraryapp.calculator.CalculatorTest.addTest(CalculatorTest.kt:16) at com.group.libraryapp.calculator.CalculatorTestKt.main(CalculatorTest.kt:5) at com.group.libraryapp.calculator.CalculatorTestKt.main(CalculatorTest.kt) Process finished with exit code 1라는 에러가 발생하는데 확인해보니 equals 메서드가 오버라이드되어 있지 않아서 발생하는 에러라고 확인을 했습니다. override fun equals(other: Any?): Boolean { if (this === other) return true if (other !is Calculator) return false return number == other.number }그래서 해당 코드를 추가해주었는데요.강의에서는 equals 오버라이드 하지 않아도 에러가 발생 안하는데 저는 발생하는 이유를 잘 몰라서 질문글에 문의를 남겨봅니다! 감사합니다.
-
미해결스프링 입문 - 코드로 배우는 스프링 부트, 웹 MVC, DB 접근 기술
자바 17, 스프링 3 버전이용중인데 에러 도와주시면 감사하겠습니다.
학습하는 분들께 도움이 되고, 더 좋은 답변을 드릴 수 있도록 질문전에 다음을 꼭 확인해주세요.1. 강의 내용과 관련된 질문을 남겨주세요.2. 인프런의 질문 게시판과 자주 하는 질문(링크)을 먼저 확인해주세요.(자주 하는 질문 링크: https://bit.ly/3fX6ygx)3. 질문 잘하기 메뉴얼(링크)을 먼저 읽어주세요.(질문 잘하기 메뉴얼 링크: https://bit.ly/2UfeqCG)질문 시에는 위 내용은 삭제하고 다음 내용을 남겨주세요.=========================================[질문 템플릿]1. 강의 내용과 관련된 질문인가요? (예/아니오)2. 인프런의 질문 게시판과 자주 하는 질문에 없는 내용인가요? (예/아니오)3. 질문 잘하기 메뉴얼을 읽어보셨나요? (예/아니오)[질문 내용]안녕하세요 cmd창으로 실행을 하였는데 강사님이 알려주신대로 해봤는데 gradlew.bat 이 실행이 안되네요저는 windows, 자바 17버젼이고 스프링은 3. 버전을 사용하고 있습니다. 도와주시면 감사하겠습니다.