묻고 답해요
148만명의 커뮤니티!! 함께 토론해봐요.
인프런 TOP Writers
-
미해결스프링과 JPA 기반 웹 애플리케이션 개발
M1 mac 에서 gradle로 빌드하시려는 분들께 공유 하고싶어 글을 남겨요!
Requirementsstatic/node_module로 package.json에 선언된 의존성을 다운로드 받아야한다gradle build 시 package.json에 선언된 의존성을 확인하고 다시 다운로드 받아야 한다.뭔가 간단하게 끝내고 싶다 !!!Actionhttps://github.com/node-gradle/gradle-node-plugin/blob/master/docs/usage.md다양한 관련 플러그인 들이 있지만, 위의 플러그인을 설치 했습니다.2번의 요구사항은 gradle의 증분 컴파일(?)이 해주는 것 같습니다. (정확하지 않음 추측이에요)3번은 관련 자료를 찾던 도중 processResources 를 발견했고, Copies production resources into the production resources directory. 라고 설명 되어 있습니다.(공식 홈페이지)따라서, npm install 시 node_module 파일을 static 이하로 떨어 뜨리면 되겠구나!그리고 processResources를 "npm install 동작을하는 " Task를 의존하게 하면 되겠구나!-- 주석이 많아 가독성이 떨어지지만, 한번 읽어보시면 더 도움이 될거라 생각해서 위의 깃헙에 있는 주석 그대로 복사 붙여넣기 합니다. 수정한 부분은 nodeProjectDir 부분과processResources.dependsOn 부분 입니다.추가로 package.json 도 아래분이 잘 정리 해주셔서 함께 복사 붙여넣기 합니다.(고맙습니다!!)-인텔리제이 빌드시(gradle로 설정안했을 경우 동작안해요!)-gradle 탭 누르셔서 npm Task 들어오는지 확인해주세요!{ "name": "static", "version": "1.0.0", "description": "", "main": "index.js", "scripts": { "test": "echo \"Error: no test specified\" && exit 1" }, "author": "", "license": "ISC", "dependencies": { "@yaireo/tagify": "^3.5.1", "bootstrap": "^4.4.1", "cropper": "^4.1.0", "font-awesome": "^4.7.0", "jdenticon": "^2.2.0", "jquery": "^3.4.1", "jquery-cropper": "^1.0.1", "mark.js": "^8.11.1", "moment": "^2.24.0", "summernote": "^0.8.16" } }plugins { id "com.github.node-gradle.node" version "3.5.0" id 'org.springframework.boot' version '2.7.5' id 'io.spring.dependency-management' version '1.0.15.RELEASE' id 'java' } group = 'me.studyOlle' version = '0.0.1-SNAPSHOT' sourceCompatibility = '17' configurations { compileOnly { extendsFrom annotationProcessor } } repositories { mavenCentral() } node { // Whether to download and install a specific Node.js version or not // If false, it will use the globally installed Node.js // If true, it will download node using above parameters // Note that npm is bundled with Node.js download = true // Version of node to download and install (only used if download is true) // It will be unpacked in the workDir version = "16.14.0" // Version of npm to use // If specified, installs it in the npmWorkDir // If empty, the plugin will use the npm command bundled with Node.js npmVersion = "" // Version of Yarn to use // Any Yarn task first installs Yarn in the yarnWorkDir // It uses the specified version if defined and the latest version otherwise (by default) yarnVersion = "" // Base URL for fetching node distributions // Only used if download is true // Change it if you want to use a mirror // Or set to null if you want to add the repository on your own. distBaseUrl = "https://nodejs.org/dist" // Specifies whether it is acceptable to communicate with the Node.js repository over an insecure HTTP connection. // Only used if download is true // Change it to true if you use a mirror that uses HTTP rather than HTTPS // Or set to null if you want to use Gradle's default behaviour. allowInsecureProtocol = null // The npm command executed by the npmInstall task // By default it is install but it can be changed to ci npmInstallCommand = "install" // The directory where Node.js is unpacked (when download is true) workDir = file("${project.projectDir}/.gradle/nodejs") // The directory where npm is installed (when a specific version is defined) npmWorkDir = file("${project.projectDir}/.gradle/npm") // The directory where yarn is installed (when a Yarn task is used) yarnWorkDir = file("${project.projectDir}/.gradle/yarn") // The Node.js project directory location // This is where the package.json file and node_modules directory are located // By default it is at the root of the current project nodeProjectDir = file("${project.projectDir}/src/main/resources/static") // Whether the plugin automatically should add the proxy configuration to npm and yarn commands // according the proxy configuration defined for Gradle // Disable this option if you want to configure the proxy for npm or yarn on your own // (in the .npmrc file for instance) nodeProxySettings = ProxySettings.SMART } dependencies { // View Template Engine implementation 'org.springframework.boot:spring-boot-starter-thymeleaf' // Security implementation 'org.springframework.boot:spring-boot-starter-security' implementation 'org.thymeleaf.extras:thymeleaf-extras-springsecurity5' //Web implementation 'org.springframework.boot:spring-boot-starter-mail' implementation 'org.springframework.boot:spring-boot-starter-web' implementation group: 'org.springframework.boot', name: 'spring-boot-starter-validation', version: '2.7.5' //Persistence implementation 'org.springframework.boot:spring-boot-starter-data-jpa' runtimeOnly 'com.h2database:h2' runtimeOnly 'com.mysql:mysql-connector-j' // LomBok compileOnly 'org.projectlombok:lombok' annotationProcessor 'org.projectlombok:lombok' // Dev developmentOnly 'org.springframework.boot:spring-boot-devtools' annotationProcessor 'org.springframework.boot:spring-boot-configuration-processor' //Test Implementation testImplementation 'org.springframework.boot:spring-boot-starter-test' testImplementation 'org.springframework.security:spring-security-test' } tasks.named('test') { useJUnitPlatform() } processResources.dependsOn('npmInstall')
-
미해결Spring Cloud로 개발하는 마이크로서비스 애플리케이션(MSA)
Filter 람다식 관련 질문드립니다.
안녕하세요!Custim Filter 강의 중 아래 코드 부분에서 GatewayFilter의 생성자가 exchange와 chain이기 때문에 return (exchange, chain) -> { .. 이 되는 것 까지는 이해를 하였습니다.그런데 이 때 exchange와 chain 변수가 어디에서 정의되어서 여기서 사용되는 건지 잘 모르겠습니다 ㅠㅠ return (exchange, chain) -> {// GatewayFilter의 생성자 Mono<Void> filter(ServerWebExchange exchange, GatewayFilterChain chain);
-
미해결스프링 입문 - 코드로 배우는 스프링 부트, 웹 MVC, DB 접근 기술
변수명 일괄변경
변수명 일괄 변경을 위해 shift+enter , shift+f6 둘다 아무 반응이 없습니다...ㅠㅠㅠㅠㅠㅠ...맥북입니다
-
해결됨Spring Boot JWT Tutorial
WebSecurityConfigurerAdapter deprecated
WebSecurityConfigurerAdapter 가 이제 더 이상 지원을 하지 않는다고 하여 WebSecurityFilterChain으로 하래서 시도중인데 계속하여 401 에러가 뜹니다...@EnableWebSecurity public class SecurityConfig { @Bean public SecurityFilterChain filterChain(HttpSecurity http) throws Exception{ http .authorizeRequests() .antMatchers("api/hello").permitAll() .anyRequest().authenticated(); return http.build(); } }
-
해결됨스프링 입문 - 코드로 배우는 스프링 부트, 웹 MVC, DB 접근 기술
부모클래스 변수로 자식클래스 인스턴스 받기
학습하는 분들께 도움이 되고, 더 좋은 답변을 드릴 수 있도록 질문전에 다음을 꼭 확인해주세요.1. 강의 내용과 관련된 질문을 남겨주세요.2. 인프런의 질문 게시판과 자주 하는 질문(링크)을 먼저 확인해주세요.(자주 하는 질문 링크: https://bit.ly/3fX6ygx)3. 질문 잘하기 메뉴얼(링크)을 먼저 읽어주세요.(질문 잘하기 메뉴얼 링크: https://bit.ly/2UfeqCG)질문 시에는 위 내용은 삭제하고 다음 내용을 남겨주세요.=========================================[질문 템플릿]1. 강의 내용과 관련된 질문인가요? (예/아니오)2. 인프런의 질문 게시판과 자주 하는 질문에 없는 내용인가요? (예/아니오)3. 질문 잘하기 메뉴얼을 읽어보셨나요? (예/아니오)[질문 내용]여기에 질문 내용을 남겨주세요.강사님은MemberRepository memberRepository = new MemoryMemberRepository();또는List<Member> result = new ArrayList<>(); 와 같이인스턴스를 받는 변수의 class 타입을 부모 클래스로 하시는데 이건 특별한 이유가 있는건가요? 아니면 코딩 스타일상 선호해서 부모 클래스 변수를 사용하시나요?
-
해결됨실전! 스프링 부트와 JPA 활용1 - 웹 애플리케이션 개발
repository 작성 시 , spring-data-jpa 의 jpaRepository 와 persistence manager 객체 주입의 선택 기준
질문 : 실제 작업을 할때, 어떤 경우에 spring-data-jpa의 jpa repository 를 쓰고, 어떤 경우에 EntityManager 를 써야 할까요 ? 안녕하세요. 선생님 이번 강의에 spring-data-jpa 의 jpa repository 를 사용하지 않고 EntityManager 를 주입받아 repository 를 사용 하는 이유는 학습의 목표가 jpa 의 동작을 더 잘 이해하기 위함이라고 들엇습니다.( 출처 : https://www.inflearn.com/questions/549972)그러면 실제 작업을 할때, 어떤 경우에 spring-data-jpa의 jpa repository 를 쓰고, 어떤 경우에 EntityManager 를 써야 할까요 ? 하나의 트랜잭션의 명령을 길게 여러개 쓰고 싶으면 jpa repository 의 함수를 직접 작성한다라고 이해해도 될까요 ?
-
해결됨스프링 입문 - 코드로 배우는 스프링 부트, 웹 MVC, DB 접근 기술
JPA 테스트하는 과정에서 질문드립니다!
JPA 강의 17:36에서 콘솔 창에 values 값으로 null 이 들어가게 되는데, 제 출력 화면에는default 값이 나옵니다.문제 없는 결과일까요??
-
해결됨Spring Boot JWT Tutorial
!user.isActivated가 계속 오류납니다
eclipse로 따라하는중인데 계속 오류가나요..
-
해결됨스프링 입문 - 코드로 배우는 스프링 부트, 웹 MVC, DB 접근 기술
@RequestParam("name")
학습하는 분들께 도움이 되고, 더 좋은 답변을 드릴 수 있도록 질문전에 다음을 꼭 확인해주세요.1. 강의 내용과 관련된 질문을 남겨주세요.2. 인프런의 질문 게시판과 자주 하는 질문(링크)을 먼저 확인해주세요.(자주 하는 질문 링크: https://bit.ly/3fX6ygx)3. 질문 잘하기 메뉴얼(링크)을 먼저 읽어주세요.(질문 잘하기 메뉴얼 링크: https://bit.ly/2UfeqCG)질문 시에는 위 내용은 삭제하고 다음 내용을 남겨주세요.=========================================[질문 템플릿]1. 강의 내용과 관련된 질문인가요? (예/아니오)2. 인프런의 질문 게시판과 자주 하는 질문에 없는 내용인가요? (예/아니오)3. 질문 잘하기 메뉴얼을 읽어보셨나요? (예/아니오)[질문 내용]여기에 질문 내용을 남겨주세요.MVC 강의를 듣다가 궁금한 부분이 생겨서 질문남깁니다.public String helloMvc(@RequestParam("name") String name, Model model) 에서 @RequestParam("name")를 없애고 서버를 켰습니다. 그랫더니이렇게 화면이 나오는데요. @RequestParam("name")가 없어도 파라미터를 잘 넘겨받는 것 처럼 보이는데, 이게 왜 필요한 건가요? 단순히 requried=true를 강제하기 위해 사용하는 건가요?
-
해결됨스프링 입문 - 코드로 배우는 스프링 부트, 웹 MVC, DB 접근 기술
libs파일이 없네요...
[질문 내용]gradle환경 만드는 과정에서 말씀해주신 대로 윈도우 환경에서 gradle.build를 하여서build successful이 나왔는데, 자꾸 cd build에 있는 libs파일이 없다고 나오네요. 실제로 들어가보니 libs파일이 없는데재 설치해도 마찬가지입니다. 환경변수 모두 java11로 되어있고 모든 setting이 java11로 되어있는데도 에러가 나니, 다음 과정으로 넘어갈 수가 없네요..
-
해결됨스프링 시큐리티
2) 필터 초기화와 다중 보안 설정 강좌
WebSecurityConfigurerAdapter가 deparcated된 후 SecurityFilterChain을 빈으로 등록하여 사용중인데, @Order를 사용하지 않아도 두 개의 SecurityConfig 클래스가 충돌이 나지는 않습니다.그런데 순서를 명시적으로 보장하기 위하여 @Order를 사용해도 원하는 순서대로 등록이 되지 않고 클래스 이름의 오름차순으로 먼저 호출되어 Bean으로 등록 됩니다. 이렇게 하는 것이 좋은 방법은 아닌 거 같아 여쭤봅니다. 다른 방법이 있을까요?
-
미해결실전! 스프링 부트와 JPA 활용1 - 웹 애플리케이션 개발
html에서 form 데이터를 받는 것에 대한 질문입니다.
html에서 form 데이터를 받는 것에 대한 질문입니다.html form 에서 보내는 데이터를 Controller에서 ModelForm으로 받고 있는데여기에 대한 질문입니다.저 ModelForm으로 값을 받을수 있는 이유가 form태그 안에 name값을 넣어준 input태그들과 매칭되어서 값을 받아 올수 있는건가요?아니면 form 태그에 명시한 th:object에 의해서 memberForm형태로 넘길 수 있는건가요?
-
미해결스프링 배치
강의자료 문의드립니다.
안녕하세요. 제가 MAC을 사용해서요.강의자료 PDF로도 혹시 제공 가능한가요. ㅠㅠ 감사합니다.
-
미해결스프링 입문 - 코드로 배우는 스프링 부트, 웹 MVC, DB 접근 기술
HTML 질문드립니다
[질문 템플릿]1. 강의 내용과 관련된 질문인가요? (예)2. 인프런의 질문 게시판과 자주 하는 질문에 없는 내용인가요? (예)3. 질문 잘하기 메뉴얼을 읽어보셨나요? (예)[질문 내용]안녕하세요. 강의 내용을 보면 영한님께서 직접 html을 작성하지는 않지만, html 내용이 종종 나오는데 그럼 스프링 강의를 학습하기전에 html도 먼저 학습을 한후에 진행해야할까요??
-
해결됨스프링 입문 - 코드로 배우는 스프링 부트, 웹 MVC, DB 접근 기술
input type name = name이 MemberForm에 String name 객체에 왜 주입되는지 모르겠습니다.
input type name 에 "name"이랑 일치하는 이름을 가진 객체한테 스프링이 주입해주는 건가요?
-
미해결스프링 배치
batch 관련 빈들을 proxy 객체로 생성하는 이유가 뭘까요?
안녕하세요batch 관련 빈들을 proxy 객체로 생성하는 이유가 뭘까요?@EnableBatchProcessing 어노테이션에 의해 SimpleBatchConfiguration.java 설정이 적용되는데요!이 설정에서 배치와 관련한 중요 빈들을 생성하는것을 볼 수 있는데* jobRepository* jobLauncher* jobBuilderFactory* stepBuilderFactory궁금한점은 이 빈들에 대해 왜 프록시로(createLazyProxy()) 생성하는걸까요?보통 프록시로 생성되어야 하는 빈들은 빈후처리기에 의해서 필요에 따라 선택되는걸로 알고있거든요아마도, 빈초기화 시점에 BatchConfigurer.class와 과련이 있어 보이는데, 정확히 알지 못하겠습니다.
-
미해결스프링 입문 - 코드로 배우는 스프링 부트, 웹 MVC, DB 접근 기술
<html xmlns:th="http://www.thymeleaf.org">
[질문 템플릿]1. 강의 내용과 관련된 질문인가요? (예/아니오)2. 인프런의 질문 게시판과 자주 하는 질문에 없는 내용인가요? (예/아니오)3. 질문 잘하기 메뉴얼을 읽어보셨나요? (예/아니오)[질문 내용]<html xmlns:th="http://www.thymeleaf.org"> 을 인식하지 못한다고 나옵니다! 어떤식으로 해결해야 할까요?
-
미해결실전! 스프링 부트와 JPA 활용2 - API 개발과 성능 최적화
Dto의 위치
엔티티를 조회해서 dto로 변환할 시에 강사님은 controller에 내부 클래스 방식을 이용하셨습니다. 그 이유가 어차피 dto가 화면에 의존적이기 때문에 controller에 내부클래스 방식으로 하신건지아니면원래는 따로 dto페키지를 만들어서 사용하는 게 맞으나 수업을 위해서 그러신건지 궁금합니다.결론적으로는 dto의 위치를 어떻게 가져가는 것이 맞는 지 궁금합니다.controller의 내부 클래스dto페키지생성repository그 외4가지 중 어디에 두어야 할 지 궁금합니다.
-
미해결스프링 시큐리티
AjaxAuthenticationProvider가 ProviderManager에게 등록이 안됩니다.
@Configuration @Order(0) public class AjaxSecurityConfig { private AuthenticationConfiguration authenticationConfiguration; @Autowired private void setAjaxSecurityConfig(AuthenticationConfiguration authenticationConfiguration) { this.authenticationConfiguration = authenticationConfiguration; } @Bean public AuthenticationProvider ajaxAuthenticationProvider() { return new AjaxAuthenticationProvider(); } @Bean public AuthenticationManager authenticationManager(AuthenticationConfiguration authenticationConfiguration) throws Exception { return authenticationConfiguration.getAuthenticationManager(); } @Bean public SecurityFilterChain ajaxFilterChain(HttpSecurity http) throws Exception { AuthenticationManagerBuilder authenticationManagerBuilder = http.getSharedObject(AuthenticationManagerBuilder.class); authenticationManagerBuilder.authenticationProvider(ajaxAuthenticationProvider()); http .antMatcher("/api/**") .authorizeRequests() .anyRequest().authenticated() .and() .addFilterBefore(ajaxLoginProcessingFilter(), UsernamePasswordAuthenticationFilter.class); http.csrf().disable(); return http.build(); } @Bean public AjaxLoginProcessingFilter ajaxLoginProcessingFilter() throws Exception { AjaxLoginProcessingFilter ajaxLoginProcessingFilter = new AjaxLoginProcessingFilter(); ajaxLoginProcessingFilter.setAuthenticationManager(authenticationManager(authenticationConfiguration)); return ajaxLoginProcessingFilter; } }AjaxSecurityConfig.java AjaxAuthenticationProvider.java@Component public class AjaxAuthenticationProvider implements AuthenticationProvider { private UserDetailsService userDetailsService; private PasswordEncoder passwordEncoder; @Autowired private void setAjaxAuthenticationProvider(UserDetailsService userDetailsService, PasswordEncoder passwordEncoder) { this.userDetailsService = userDetailsService; this.passwordEncoder = passwordEncoder; } @Override @Transactional public Authentication authenticate(Authentication authentication) throws AuthenticationException { AccountContext accountContext = FormAuthenticationProvider.authenticationIf(authentication, userDetailsService, passwordEncoder); return new AjaxAuthenticationToken(accountContext.getAccount(), null, accountContext.getAuthorities()); } @Override public boolean supports(Class<?> authentication) { return authentication.equals(AjaxAuthenticationToken.class); } } 설정을 모두 완료하고 확인해보니 Filter는 정상적으로 등록이 되고, ProviderManager에 넘기는 것 까지는 진행이 됩니다. 그런대 ProviderManager에 BreakPoint를 걸고 확인해 보니 DaoAuthenticationProvider만 providers에 등록이 되어있습니다. 그래서 Form 방식을 확인해 보니 Form은 정상작동 하는 것을 확인했습니다. 혹시 자세한 코드가 필요하시다면 아래 링크의 브런치 ch4.3입니다. 항상 모든 질문에 최선을 다해 답변해 주시니 감사합니다.추가 사항으로 SecurityConfig에 넣어서 돌렸더니 Provider가 정상적으로 추가되는 것을 확인했습니다. 또한 오류는 인식하고, AjaxAuthenticationFailureHandler는 또 호출을 합니다. 점점 뭐가 문제인지 잘 모르겠습니다.Othkkartho/SpringSecurityLearn at ch4.3 (github.com)
-
미해결실전! 스프링 부트와 JPA 활용2 - API 개발과 성능 최적화
@Data의 역할
왜 Dto에 @Data가 빠지면이런 오류가 나는 지 궁금합니다.강의에서는 getter가 없어서 오류가 났다고 배웠습니다.property가 없다고 오류가 난다고 배웠는데 왜 getter가 있어야 하는 지 궁금합니다.