(메인 클래스 부분 아래로 내려가지지 않아서 실행 결과를 여기에 먼저 올립니다 😅) 참고로, 함수형 인터페이스를 사용할 때는 아래와 같이 함수 시그니처(함수 이름, 반환형, 파라미터 타입)만 동일하고 바디 부분은 달라도 정상적으로 실행이 되더군요. 📋Reportable 인터페이스 package practice; @FunctionalInterface public interface Reportable { void report(int time); // 신고 } 📋Detectable 인터페이스 package practice.detector; @FunctionalInterface public interface Detectable { String name = "감지자"; // 인터페이스도 필드를 가질 수 있음 void detect(); // 감지 } 💻NormalReporter 클래스 package practice; public class NormalReporter implements Reportable { @Override public void report(int time) { System.out.println(time + " 초 동안 일반 화재 신고를 진행합니다."); } } 💻VideoReporter 클래스 package practice; public class VideoReporter implements Reportable { @Override public void report(int time) { System.out.println("직전 " + time + "초 영상과 함께 신고를 진행합니다."); } } 💻FireDetector 클래스 package practice.detector; public class FireDetector implements Detectable{ @Override public void detect() { System.out.println("일반 성능으로 화재를 감지합니다."); } } 💻AdvancedFireDetector 클래스 package practice.detector; public class AdvancedFireDetector implements Detectable{ @Override public void detect() { System.out.println("향상된 성능으로 화재를 감지합니다."); } } 💻메인 클래스 package practice; import practice.detector.Detectable; public class practice { public static void main(String[] args) { //* 함수형 인터페이스 실행 Reportable reportableNormal = (time) -> System.out.println(time + " 초 동안 일반 화재 신고를 진행합니다."); Reportable reportableVideo = (time) -> System.out.println("직전 " + time + "초 영상과 함께 신고를 진행합니다."); Detectable detectableFire = () -> System.out.println("일반 성능으로 화재를 감지합니다."); Detectable detectableAdvancedFire = () -> System.out.println("향상된 성능으로 화재를 감지합니다."); reportbyNormalReporter(reportableNormal, 20); reportbyVideoReporter(reportableVideo, 10); detectbyFireDetector(detectableFire); detectbyAdvancedFireDetector(detectableAdvancedFire); } public static void reportbyNormalReporter(Reportable reporter, int time) { reporter.report(time); } public static void reportbyVideoReporter(Reportable reporter, int time) { reporter.report(time); } public static void detectbyFireDetector(Detectable detector) { detector.detect(); } public static void detectbyAdvancedFireDetector(Detectable detector) { detector.detect(); } }
엄밀하게 따지면 JAVA는 모두 call by value로 알고 있습니다. call by reference 방식은 실제 메모리의 주소값을 전달하여 원본 자체의 주소가 바뀌는 방식으로 알고있습니다. 반면 자바에서 reference type을 메서드로 전달하여 값이 바뀌는건, 메서드내에서 reference type 의 주소를 복사받아. 주소의 변화 없이 값만 조정하는걸로 압니다. 즉 메서드 내에서 전달받은 복사된 주소값으로, 해당 객체나 배열의 값을 수정하는거지. 원본 자체의 변화는 없는걸로 학습했는데, 제가 학습한게 맞을까요?
3일내내 봐도 도저히 모르겠습니다. member를 인식을 못해서 나오는 오류같은데... 왜그러는지 모르겠네요 https://drive.google.com/file/d/14g_0hPnQMDfxNpcRIfCwjEczhci0loYu/view?usp=drive_link 드라이브 링크 올리고 OrderApp 에서 실행시키면 null point 나옵니다. 도와주세요
섹션7 - 다양한 의존관계 주입 방법 수강 중입니다. 수정자 주입 방식에서 주입할 파라미터가 없다면 오류가 발생한다는 부분에서 궁금한게 있습니다. 주입할 파라미터가 Bean 객체 대상인데 아직 생성되지 않으면 그것을 먼저 생성해주고 주입하는 것이 맞나요? 파라미터가 1개이고 Bean 객체 대상이 아니면 굳이 required = false해주지 말고 아예 Autowired 애노테이션을 작성하지 않아도 되는건가요?
클래스의 상속과 관련된 다형성은 부모객체로 인스턴스를 생성하여 부모클래스의 메소드와 자식클래스 메소드 2가지를 업/다운캐스팅하여 자유롭게 호출할 수 있지만, 단일상속이라는 한계 때문에 다른 부모클래스의 메소드는 호출할 수가 없잖아요? 그래서 인터페이스가 존재하는 이유구요. 마찬가지로, 인스턴스를 생성할 때 다형성을 활용하여 인터페이스 객체(부모 객체)로 생성할 수는 있지만, 이것은 ISP(Interface Segregation Principle)원칙에 따라 detect(), report() 2개의 메소드를 호출하려면 Detectable, Reportable 객체 2개를 생성해야 하기 때문에 메모리가 효율적으로 관리되지 못하는거구요. 따라서 구상클래스인 FactoryCam에서 인터페이스 변수를 직접 생성하고 setter함수로 필요한 인터페이스 변수를 주입한 다음(Dependency Injection) , 주입당한 객체는 인터페이스에 의존하기 때문에(Reportable, Detectable) 동시에 기능이 다른 2가지 메소드를 호출할 수 있는거구요.(Dependency Inversion Principle) ... 과정을 이해하였지만 말로 풀어내니까 굉장히 장황하군요 사실 이 부분은 인터페이스 문법이라기보다는 디자인 패턴과 관련이 있지 않나싶습니다.
학습하는 분들께 도움이 되고, 더 좋은 답변을 드릴 수 있도록 질문전에 다음을 꼭 확인해주세요. 1. 강의 내용과 관련된 질문을 남겨주세요. 2. 인프런의 질문 게시판과 자주 하는 질문(링크)을 먼저 확인해주세요. (자주 하는 질문 링크: https://bit.ly/3fX6ygx) 3. 질문 잘하기 메뉴얼(링크)을 먼저 읽어주세요. (질문 잘하기 메뉴얼 링크: https://bit.ly/2UfeqCG) 질문 시에는 위 내용은 삭제하고 다음 내용을 남겨주세요. ========================================= [질문 템플릿] 1. 강의 내용과 관련된 질문인가요? (예/아니오) 2. 인프런의 질문 게시판과 자주 하는 질문에 없는 내용인가요? (예/아니오) 3. 질문 잘하기 메뉴얼을 읽어보셨나요? (예/아니오) [질문 내용] 여기에 질문 내용을 남겨주세요. 제가 작성한 OrderServiceImpl 코드가 이건데 같은 이름의 클래스 두개가있어서 하나를 삭제했더니 에러가 많이 생기는데 혹시 OrderserviceImpl 전체 코드 알 수 있을까요?? import hello.core.discount .DiscountPolicy; import hello.core.member.Member; import hello.core.member.MemberRepository; import hello.core.order.Order; import hello.core.order.OrderService; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; @Component public class OrderServiceImpl implements OrderService { private final MemberRepository memberRepository; private final DiscountPolicy discountPolicy; @Autowired public OrderServiceImpl(MemberRepository memberRepository, DiscountPolicy discountPolicy) { this.memberRepository = memberRepository; this.discountPolicy = discountPolicy; } @Override public Order createOrder(Long memberId, String itemName, int itemPrice) { Member member = memberRepository.findById(memberId); int discountPrice = discountPolicy.discount (member, itemPrice); return new Order(memberId, itemName, itemPrice, discountPrice); } public MemberRepository getMemberRepository() { return memberRepository; } }
학습하는 분들께 도움이 되고, 더 좋은 답변을 드릴 수 있도록 질문전에 다음을 꼭 확인해주세요. 1. 강의 내용과 관련된 질문을 남겨주세요. 2. 인프런의 질문 게시판과 자주 하는 질문(링크)을 먼저 확인해주세요. (자주 하는 질문 링크: https://bit.ly/3fX6ygx) 3. 질문 잘하기 메뉴얼(링크)을 먼저 읽어주세요. (질문 잘하기 메뉴얼 링크: https://bit.ly/2UfeqCG) 질문 시에는 위 내용은 삭제하고 다음 내용을 남겨주세요. ========================================= [질문 템플릿] 1. 강의 내용과 관련된 질문인가요? (예/아니오) 2. 인프런의 질문 게시판과 자주 하는 질문에 없는 내용인가요? (예/아니오) 3. 질문 잘하기 메뉴얼을 읽어보셨나요? (예/아니오) [질문 내용] 여기에 질문 내용을 남겨주세요. 스프링 부트로 프로젝트 생성했는데 build.gradle, gitignore등에 빨간색이 생겨요 어떻게 해결해야하나요
안녕하세요 선생님 파이썬 기본 문법 강의부터 잘 들었던 학생입니다 ㅎㅎ 메소드 오버로딩 강의를 듣다가 메소드 오버로딩의 목적이 잘 이해가 가지 않아서 구글링을 해보았는데요, TCP 스쿨 문서에 '이러한 메소드 오버로딩을 사용함으로써 메소드에 사용되는 이름을 절약할 수 있습니다. 또한, 메소드를 호출할 때 전달해야 할 매개변수의 타입이나 개수에 대해 크게 신경을 쓰지 않고 호출할 수 있게 됩니다. 메소드 오버로딩은 객체 지향 프로그래밍의 특징 중 하나인 다형성(polymorphism)을 구현하는 방법 중 하나입니다.' 라고 답변이 나와있어 몇가지 질문드립니다. 메소드 오버로딩은 메소드에 사용되는 이름을 절약하는 것이 있고 다른 목적이 또 있을까요? 여기서 객체 지향 프로그래밍의 특징 중 하나인 '다형성'이라고 나오는데 다형성을 쉽게 이해할 수 있는 방법이 있을까요? 메소드 오버로딩의 대표적인 예로는 println() 메소드를 들 수 있다고하는데 자바 프로그래밍 언어를 창시할때 println()을 만들었을시, 해당 함수를 의미하는 것일까요? 항상 너무 감사하게 잘 듣고있습니다 친절하게 알려주셔서 정말 감사합니다 선생님 태풍 조심하시고 항상 건강하시고 행복한 하루 보내시길 바랍니다 :)
학습하는 분들께 도움이 되고, 더 좋은 답변을 드릴 수 있도록 질문전에 다음을 꼭 확인해주세요. 1. 강의 내용과 관련된 질문을 남겨주세요. 2. 인프런의 질문 게시판과 자주 하는 질문(링크)을 먼저 확인해주세요. (자주 하는 질문 링크: https://bit.ly/3fX6ygx) 3. 질문 잘하기 메뉴얼(링크)을 먼저 읽어주세요. (질문 잘하기 메뉴얼 링크: https://bit.ly/2UfeqCG) 질문 시에는 위 내용은 삭제하고 다음 내용을 남겨주세요. ========================================= [질문 템플릿] 1. 강의 내용과 관련된 질문인가요? (예/아니오) 2. 인프런의 질문 게시판과 자주 하는 질문에 없는 내용인가요? (예/아니오) 3. 질문 잘하기 메뉴얼을 읽어보셨나요? (예/아니오) [질문 내용] 여기에 질문 내용을 남겨주세요. 잘 따라서 수업듣고 있는데 왜 이런 에러가 뜨는지 도저히 모르겠습니다.
학습하는 분들께 도움이 되고, 더 좋은 답변을 드릴 수 있도록 질문전에 다음을 꼭 확인해주세요. 1. 강의 내용과 관련된 질문을 남겨주세요. 2. 인프런의 질문 게시판과 자주 하는 질문(링크)을 먼저 확인해주세요. (자주 하는 질문 링크: https://bit.ly/3fX6ygx) 3. 질문 잘하기 메뉴얼(링크)을 먼저 읽어주세요. (질문 잘하기 메뉴얼 링크: https://bit.ly/2UfeqCG) 질문 시에는 위 내용은 삭제하고 다음 내용을 남겨주세요. ========================================= [질문 템플릿] 1. 강의 내용과 관련된 질문인가요? (예/아니오) 2. 인프런의 질문 게시판과 자주 하는 질문에 없는 내용인가요? (예/아니오) 3. 질문 잘하기 메뉴얼을 읽어보셨나요? (예/아니오) [질문 내용] 여기에 질문 내용을 남겨주세요. package hello.core.order; import hello.core.discount .DiscountPolicy; import hello.core.discount .FixDiscountPolicy; import hello.core.member.Member; import hello.core.member.MemberRepository; import hello.core.member.MemoryMemberRepository; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; @Component public class OrderServiceImpl implements OrderService{ private final MemberRepository memberRepository; private final DiscountPolicy discountPolicy; @Autowired public OrderServiceImpl(MemberRepository memberRepository, DiscountPolicy rateDiscountPolicy) { this.memberRepository = memberRepository; this.discountPolicy = rateDiscountPolicy; } @Override public Order createOrder(Long memberId, String itemName, int itemPrice) { Member member = memberRepository.findById(memberId); int discountPrice = discountPolicy.discount (member, itemPrice); return new Order(memberId, itemName, itemPrice, discountPrice); } public MemberRepository getMemberRepository() { return memberRepository; } public void setMemberRepository(MemoryMemberRepository memoryMemberRepository) { } public void setDiscountPolicy(FixDiscountPolicy fixDiscountPolicy) { } } OrderServiceImpl 코드입니다...! AutoAppConfigTest 실행하면 에러가 나는데 어디가 문제일까요...?! 에러코드는 이렇습니다! "C:\Program Files\Java\jdk-11\bin\java.exe" -ea -Didea.test.cyclic.buffer.size=1048576 "-javaagent:C:\Program Files\JetBrains\IntelliJ IDEA 2023.1.4\lib\idea_rt.jar=62798:C:\Program Files\JetBrains\IntelliJ IDEA 2023.1.4\bin" -Dfile.encoding=UTF-8 -classpath "C:\Users\Lets Go Rust\.m2\repository\org\junit\platform\junit-platform-launcher\1.8.2\junit-platform-launcher-1.8.2.jar;C:\Users\Lets Go Rust\.m2\repository\org\junit\platform\junit-platform-engine\1.8.2\junit-platform-engine-1.8.2.jar;C:\Users\Lets Go Rust\.m2\repository\org\opentest4j\opentest4j\1.2.0\opentest4j-1.2.0.jar;C:\Users\Lets Go Rust\.m2\repository\org\junit\platform\junit-platform-commons\1.8.2\junit-platform-commons-1.8.2.jar;C:\Users\Lets Go Rust\.m2\repository\org\apiguardian\apiguardian-api\1.1.2\apiguardian-api-1.1.2.jar;C:\Program Files\JetBrains\IntelliJ IDEA 2023.1.4\lib\idea_rt.jar;C:\Program Files\JetBrains\IntelliJ IDEA 2023.1.4\plugins\junit\lib\junit5-rt.jar;C:\Program Files\JetBrains\IntelliJ IDEA 2023.1.4\plugins\junit\lib\junit-rt.jar;C:\core (1)\core\out\test\classes;C:\core (1)\core\out\production\classes;C:\core (1)\core\out\production\resources;C:\Users\Lets Go Rust\.gradle\caches\modules-2\files-2.1\org.springframework.boot\spring-boot-starter-test\2.7.13\c937a5716d02d8dcd64f742d12607993873e7a5a\spring-boot-starter-test-2.7.13.jar;C:\Users\Lets Go Rust\.gradle\caches\modules-2\files-2.1\org.springframework.boot\spring-boot-starter\2.7.13\5617ca04b06778877fb80d146dd2d0dd6adb23a8\spring-boot-starter-2.7.13.jar;C:\Users\Lets Go Rust\.gradle\caches\modules-2\files-2.1\org.projectlombok\lombok\1.18.28\a2ff5da8bcd8b1b26f36b806ced63213362c6dcc\lombok-1.18.28.jar;C:\Users\Lets Go Rust\.gradle\caches\modules-2\files-2.1\org.springframework.boot\spring-boot-test-autoconfigure\2.7.13\1de71639f25f4948cbe50904a1118e060c91f6a5\spring-boot-test-autoconfigure-2.7.13.jar;C:\Users\Lets Go Rust\.gradle\caches\modules-2\files-2.1\org.springframework.boot\spring-boot-test\2.7.13\be93829dcb79b788678654deefbb675045a60fb0\spring-boot-test-2.7.13.jar;C:\Users\Lets Go Rust\.gradle\caches\modules-2\files-2.1\org.springframework\spring-test\5.3.28\3a6ce360d853c9083f82196e0a4ced4ab2fe5c6b\spring-test-5.3.28.jar;C:\Users\Lets Go Rust\.gradle\caches\modules-2\files-2.1\org.springframework\spring-core\5.3.28\5b7ec246fef72fdfbb0b4123956715ca89cc6ddf\spring-core-5.3.28.jar;C:\Users\Lets Go Rust\.gradle\caches\modules-2\files-2.1\com.jayway.jsonpath\json-path\2.7.0\f9d7d9659f2694e61142046ff8a216c047f263e8\json-path-2.7.0.jar;C:\Users\Lets Go Rust\.gradle\caches\modules-2\files-2.1\jakarta.xml.bind\jakarta.xml.bind-api\2.3.3\48e3b9cfc10752fba3521d6511f4165bea951801\jakarta.xml.bind-api-2.3.3.jar;C:\Users\Lets Go Rust\.gradle\caches\modules-2\files-2.1\org.assertj\assertj-core\3.22.0\c300c0c6a24559f35fa0bd3a5472dc1edcd0111e\assertj-core-3.22.0.jar;C:\Users\Lets Go Rust\.gradle\caches\modules-2\files-2.1\org.hamcrest\hamcrest\2.2\1820c0968dba3a11a1b30669bb1f01978a91dedc\hamcrest-2.2.jar;C:\Users\Lets Go Rust\.gradle\caches\modules-2\files-2.1\org.junit.jupiter\junit-jupiter\5.8.2\5a817b1e63f1217e5c586090c45e681281f097ad\junit-jupiter-5.8.2.jar;C:\Users\Lets Go Rust\.gradle\caches\modules-2\files-2.1\org.mockito\mockito-junit-jupiter\4.5.1\f81fb60bd69b3a6e5537ae23b883326f01632a61\mockito-junit-jupiter-4.5.1.jar;C:\Users\Lets Go Rust\.gradle\caches\modules-2\files-2.1\org.mockito\mockito-core\4.5.1\ed456e623e5afc6f4cee3ae58144e5c45f3b3bf\mockito-core-4.5.1.jar;C:\Users\Lets Go Rust\.gradle\caches\modules-2\files-2.1\org.skyscreamer\jsonassert\1.5.1\6d842d0faf4cf6725c509a5e5347d319ee0431c3\jsonassert-1.5.1.jar;C:\Users\Lets Go Rust\.gradle\caches\modules-2\files-2.1\org.xmlunit\xmlunit-core\2.9.1\e5833662d9a1279a37da3ef6f62a1da29fcd68c4\xmlunit-core-2.9.1.jar;C:\Users\Lets Go Rust\.gradle\caches\modules-2\files-2.1\org.springframework.boot\spring-boot-autoconfigure\2.7.13\1b6b9605b1b116e32c372f3b9e15abf7bb17038c\spring-boot-autoconfigure-2.7.13.jar;C:\Users\Lets Go Rust\.gradle\caches\modules-2\files-2.1\org.springframework.boot\spring-boot\2.7.13\d009fa51c7792c9e510da7e69329baf39591707d\spring-boot-2.7.13.jar;C:\Users\Lets Go Rust\.gradle\caches\modules-2\files-2.1\org.springframework.boot\spring-boot-starter-logging\2.7.13\8a5e9bd6fa8341193a977d408b9a44faaa684c8d\spring-boot-starter-logging-2.7.13.jar;C:\Users\Lets Go Rust\.gradle\caches\modules-2\files-2.1\jakarta.annotation\jakarta.annotation-api\1.3.5\59eb84ee0d616332ff44aba065f3888cf002cd2d\jakarta.annotation-api-1.3.5.jar;C:\Users\Lets Go Rust\.gradle\caches\modules-2\files-2.1\org.yaml\snakeyaml\1.30\8fde7fe2586328ac3c68db92045e1c8759125000\snakeyaml-1.30.jar;C:\Users\Lets Go Rust\.gradle\caches\modules-2\files-2.1\org.springframework\spring-jcl\5.3.28\d67e8b213aa08a0f3d71e547fb4345372d819d36\spring-jcl-5.3.28.jar;C:\Users\Lets Go Rust\.gradle\caches\modules-2\files-2.1\net.minidev\json-smart\2.4.11\cc5888f14a5768f254b97bafe8b9fd29b31e872e\json-smart-2.4.11.jar;C:\Users\Lets Go Rust\.gradle\caches\modules-2\files-2.1\org.slf4j\slf4j-api\1.7.36\6c62681a2f655b49963a5983b8b0950a6120ae14\slf4j-api-1.7.36.jar;C:\Users\Lets Go Rust\.gradle\caches\modules-2\files-2.1\jakarta.activation\jakarta.activation-api\1.2.2\99f53adba383cb1bf7c3862844488574b559621f\jakarta.activation-api-1.2.2.jar;C:\Users\Lets Go Rust\.gradle\caches\modules-2\files-2.1\org.junit.jupiter\junit-jupiter-params\5.8.2\ddeafe92fc263f895bfb73ffeca7fd56e23c2cce\junit-jupiter-params-5.8.2.jar;C:\Users\Lets Go Rust\.gradle\caches\modules-2\files-2.1\org.junit.jupiter\junit-jupiter-api\5.8.2\4c21029217adf07e4c0d0c5e192b6bf610c94bdc\junit-jupiter-api-5.8.2.jar;C:\Users\Lets Go Rust\.gradle\caches\modules-2\files-2.1\net.bytebuddy\byte-buddy\1.12.23\d470526e8c4566c04e9ae5d3ccb62d1a7aa58986\byte-buddy-1.12.23.jar;C:\Users\Lets Go Rust\.gradle\caches\modules-2\files-2.1\net.bytebuddy\byte-buddy-agent\1.12.23\1cba11fdb72c383edacb909f79ae6870efd275e4\byte-buddy-agent-1.12.23.jar;C:\Users\Lets Go Rust\.gradle\caches\modules-2\files-2.1\com.vaadin.external.google\android-json\0.0.20131108.vaadin1\fa26d351fe62a6a17f5cda1287c1c6110dec413f\android-json-0.0.20131108.vaadin1.jar;C:\Users\Lets Go Rust\.gradle\caches\modules-2\files-2.1\org.springframework\spring-context\5.3.28\edf8ebfd637e3e10ec7fed697eb69f2a5229748a\spring-context-5.3.28.jar;C:\Users\Lets Go Rust\.gradle\caches\modules-2\files-2.1\ch.qos.logback\logback-classic\1.2.12\d4dee19148dccb177a0736eb2027bd195341da78\logback-classic-1.2.12.jar;C:\Users\Lets Go Rust\.gradle\caches\modules-2\files-2.1\org.apache.logging.log4j\log4j-to-slf4j\2.17.2\17dd0fae2747d9a28c67bc9534108823d2376b46\log4j-to-slf4j-2.17.2.jar;C:\Users\Lets Go Rust\.gradle\caches\modules-2\files-2.1\org.slf4j\jul-to-slf4j\1.7.36\ed46d81cef9c412a88caef405b58f93a678ff2ca\jul-to-slf4j-1.7.36.jar;C:\Users\Lets Go Rust\.gradle\caches\modules-2\files-2.1\net.minidev\accessors-smart\2.4.11\245ceca7bdf3190fbb977045c852d5f3c8efece1\accessors-smart-2.4.11.jar;C:\Users\Lets Go Rust\.gradle\caches\modules-2\files-2.1\org.apiguardian\apiguardian-api\1.1.2\a231e0d844d2721b0fa1b238006d15c6ded6842a\apiguardian-api-1.1.2.jar;C:\Users\Lets Go Rust\.gradle\caches\modules-2\files-2.1\org.junit.platform\junit-platform-commons\1.8.2\32c8b8617c1342376fd5af2053da6410d8866861\junit-platform-commons-1.8.2.jar;C:\Users\Lets Go Rust\.gradle\caches\modules-2\files-2.1\org.opentest4j\opentest4j\1.2.0\28c11eb91f9b6d8e200631d46e20a7f407f2a046\opentest4j-1.2.0.jar;C:\Users\Lets Go Rust\.gradle\caches\modules-2\files-2.1\org.springframework\spring-aop\5.3.28\aada0ea72a3efee5f02f264f90329f7eddedf321\spring-aop-5.3.28.jar;C:\Users\Lets Go Rust\.gradle\caches\modules-2\files-2.1\org.springframework\spring-beans\5.3.28\4d232acbb7031963688cf28b1b34134937892c4f\spring-beans-5.3.28.jar;C:\Users\Lets Go Rust\.gradle\caches\modules-2\files-2.1\org.springframework\spring-expression\5.3.28\d049216b1a73b939b36bbf5cc7ce734cace7b245\spring-expression-5.3.28.jar;C:\Users\Lets Go Rust\.gradle\caches\modules-2\files-2.1\ch.qos.logback\logback-core\1.2.12\1d8e51a698b138065d73baefb4f94531faa323cb\logback-core-1.2.12.jar;C:\Users\Lets Go Rust\.gradle\caches\modules-2\files-2.1\org.apache.logging.log4j\log4j-api\2.17.2\f42d6afa111b4dec5d2aea0fe2197240749a4ea6\log4j-api-2.17.2.jar;C:\Users\Lets Go Rust\.gradle\caches\modules-2\files-2.1\org.ow2.asm\asm\9.3\8e6300ef51c1d801a7ed62d07cd221aca3a90640\asm-9.3.jar;C:\Users\Lets Go Rust\.gradle\caches\modules-2\files-2.1\org.junit.jupiter\junit-jupiter-engine\5.8.2\c598b4328d2f397194d11df3b1648d68d7d990e3\junit-jupiter-engine-5.8.2.jar;C:\Users\Lets Go Rust\.gradle\caches\modules-2\files-2.1\org.objenesis\objenesis\3.2\7fadf57620c8b8abdf7519533e5527367cb51f09\objenesis-3.2.jar;C:\Users\Lets Go Rust\.gradle\caches\modules-2\files-2.1\org.junit.platform\junit-platform-engine\1.8.2\b737de09f19864bd136805c84df7999a142fec29\junit-platform-engine-1.8.2.jar" com.intellij.rt.junit.JUnitStarter -ideVersion5 -junit5 hello.core.scan.AutoAppConfigTest,basicScan 14:58:00.796 [main] DEBUG org.springframework.context.annotation.AnnotationConfigApplicationContext - Refreshing org.springframework.context.annotation.AnnotationConfigApplicationContext@4fb3ee4e 14:58:00.837 [main] DEBUG org.springframework.beans.factory.support .DefaultListableBeanFactory - Creating shared instance of singleton bean 'org.springframework.context.annotation.internalConfigurationAnnotationProcessor' 14:58:01.226 [main] DEBUG org.springframework.context.annotation.ClassPathBeanDefinitionScanner - Identified candidate component class: file [C:\core (1)\core\out\production\classes\hello\core\OrderServiceImpl.class] 14:58:01.231 [main] DEBUG org.springframework.context.annotation.ClassPathBeanDefinitionScanner - Identified candidate component class: file [C:\core (1)\core\out\production\classes\hello\core\discount\RateDiscountPolicy.class] 14:58:01.243 [main] DEBUG org.springframework.context.annotation.ClassPathBeanDefinitionScanner - Identified candidate component class: file [C:\core (1)\core\out\production\classes\hello\core\member\MemberServiceImpl.class] 14:58:01.244 [main] DEBUG org.springframework.context.annotation.ClassPathBeanDefinitionScanner - Identified candidate component class: file [C:\core (1)\core\out\production\classes\hello\core\member\MemoryMemberRepository.class] 14:58:01.249 [main] DEBUG org.springframework.context.annotation.ClassPathBeanDefinitionScanner - Identified candidate component class: file [C:\core (1)\core\out\production\classes\hello\core\order\OrderServiceImpl.class] 14:58:01.254 [main] WARN org.springframework.context.annotation.AnnotationConfigApplicationContext - Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.BeanDefinitionStoreException: Failed to parse configuration class [hello.core.AutoAppConfig]; nested exception is org.springframework.context.annotation.ConflictingBeanDefinitionException: Annotation-specified bean name 'orderServiceImpl' for bean class [hello.core.order.OrderServiceImpl] conflicts with existing, non-compatible bean definition of same name and class [hello.core.OrderServiceImpl] org.springframework.beans.factory.BeanDefinitionStoreException: Failed to parse configuration class [hello.core.AutoAppConfig]; nested exception is org.springframework.context.annotation.ConflictingBeanDefinitionException: Annotation-specified bean name 'orderServiceImpl' for bean class [hello.core.order.OrderServiceImpl] conflicts with existing, non-compatible bean definition of same name and class [hello.core.OrderServiceImpl] at org.springframework.context.annotation.ConfigurationClassParser.parse( ConfigurationClassParser.java:188 ) at org.springframework.context.annotation.ConfigurationClassPostProcessor.processConfigBeanDefinitions( ConfigurationClassPostProcessor.java:331 ) at org.springframework.context.annotation.ConfigurationClassPostProcessor.postProcessBeanDefinitionRegistry( ConfigurationClassPostProcessor.java:247 ) at org.springframework.context.support .PostProcessorRegistrationDelegate.invokeBeanDefinitionRegistryPostProcessors( PostProcessorRegistrationDelegate.java:311 ) at org.springframework.context.support .PostProcessorRegistrationDelegate.invokeBeanFactoryPostProcessors( PostProcessorRegistrationDelegate.java:112 ) at org.springframework.context.support .AbstractApplicationContext.invokeBeanFactoryPostProcessors( AbstractApplicationContext.java:748 ) at org.springframework.context.support .AbstractApplicationContext.refresh( AbstractApplicationContext.java:564 ) at org.springframework.context.annotation.AnnotationConfigApplicationContext.<init>( AnnotationConfigApplicationContext.java:93 ) at hello.core.scan.AutoAppConfigTest.basicScan( AutoAppConfigTest.java:16 ) at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke( NativeMethodAccessorImpl.java:62 ) at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke( DelegatingMethodAccessorImpl.java:43 ) at java.base/java.lang.reflect.Method.invoke( Method.java:566 ) at org.junit.platform.commons.util.ReflectionUtils.invokeMethod( ReflectionUtils.java:725 ) at org.junit.jupiter.engine.execution.MethodInvocation.proceed( MethodInvocation.java:60 ) at org.junit.jupiter.engine.execution.InvocationInterceptorChain$ValidatingInvocation.proceed( InvocationInterceptorChain.java:131 ) at org.junit.jupiter.engine.extension.TimeoutExtension.intercept( TimeoutExtension.java:149 ) at org.junit.jupiter.engine.extension.TimeoutExtension.interceptTestableMethod( TimeoutExtension.java:140 ) at org.junit.jupiter.engine.extension.TimeoutExtension.interceptTestMethod( TimeoutExtension.java:84 ) at org.junit.jupiter.engine.execution.ExecutableInvoker$ReflectiveInterceptorCall.lambda$ofVoidMethod$0( ExecutableInvoker.java:115 ) at org.junit.jupiter.engine.execution.ExecutableInvoker.lambda$invoke$0( ExecutableInvoker.java:105 ) at org.junit.jupiter.engine.execution.InvocationInterceptorChain$InterceptedInvocation.proceed( InvocationInterceptorChain.java:106 ) at org.junit.jupiter.engine.execution.InvocationInterceptorChain.proceed( InvocationInterceptorChain.java:64 ) at org.junit.jupiter.engine.execution.InvocationInterceptorChain.chainAndInvoke( InvocationInterceptorChain.java:45 ) at org.junit.jupiter.engine.execution.InvocationInterceptorChain.invoke( InvocationInterceptorChain.java:37 ) at org.junit.jupiter.engine.execution.ExecutableInvoker.invoke( ExecutableInvoker.java:104 ) at org.junit.jupiter.engine.execution.ExecutableInvoker.invoke( ExecutableInvoker.java:98 ) at org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.lambda$invokeTestMethod$7( TestMethodTestDescriptor.java:214 ) at org.junit.platform.engine.support .hierarchical.ThrowableCollector.execute( ThrowableCollector.java:73 ) at org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.invokeTestMethod( TestMethodTestDescriptor.java:210 ) at org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.execute( TestMethodTestDescriptor.java:135 ) at org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.execute( TestMethodTestDescriptor.java:66 ) at org.junit.platform.engine.support .hierarchical.NodeTestTask.lambda$executeRecursively$6( NodeTestTask.java:151 ) at org.junit.platform.engine.support .hierarchical.ThrowableCollector.execute( ThrowableCollector.java:73 ) at org.junit.platform.engine.support .hierarchical.NodeTestTask.lambda$executeRecursively$8( NodeTestTask.java:141 ) at org.junit.platform.engine.support .hierarchical.Node.around( Node.java:137 ) at org.junit.platform.engine.support .hierarchical.NodeTestTask.lambda$executeRecursively$9( NodeTestTask.java:139 ) at org.junit.platform.engine.support .hierarchical.ThrowableCollector.execute( ThrowableCollector.java:73 ) at org.junit.platform.engine.support .hierarchical.NodeTestTask.executeRecursively( NodeTestTask.java:138 ) at org.junit.platform.engine.support .hierarchical.NodeTestTask.execute( NodeTestTask.java:95 ) at java.base/java.util.ArrayList.forEach( ArrayList.java:1541 ) at org.junit.platform.engine.support .hierarchical.SameThreadHierarchicalTestExecutorService.invokeAll( SameThreadHierarchicalTestExecutorService.java:41 ) at org.junit.platform.engine.support .hierarchical.NodeTestTask.lambda$executeRecursively$6( NodeTestTask.java:155 ) at org.junit.platform.engine.support .hierarchical.ThrowableCollector.execute( ThrowableCollector.java:73 ) at org.junit.platform.engine.support .hierarchical.NodeTestTask.lambda$executeRecursively$8( NodeTestTask.java:141 ) at org.junit.platform.engine.support .hierarchical.Node.around( Node.java:137 ) at org.junit.platform.engine.support .hierarchical.NodeTestTask.lambda$executeRecursively$9( NodeTestTask.java:139 ) at org.junit.platform.engine.support .hierarchical.ThrowableCollector.execute( ThrowableCollector.java:73 ) at org.junit.platform.engine.support .hierarchical.NodeTestTask.executeRecursively( NodeTestTask.java:138 ) at org.junit.platform.engine.support .hierarchical.NodeTestTask.execute( NodeTestTask.java:95 ) at java.base/java.util.ArrayList.forEach( ArrayList.java:1541 ) at org.junit.platform.engine.support .hierarchical.SameThreadHierarchicalTestExecutorService.invokeAll( SameThreadHierarchicalTestExecutorService.java:41 ) at org.junit.platform.engine.support .hierarchical.NodeTestTask.lambda$executeRecursively$6( NodeTestTask.java:155 ) at org.junit.platform.engine.support .hierarchical.ThrowableCollector.execute( ThrowableCollector.java:73 ) at org.junit.platform.engine.support .hierarchical.NodeTestTask.lambda$executeRecursively$8( NodeTestTask.java:141 ) at org.junit.platform.engine.support .hierarchical.Node.around( Node.java:137 ) at org.junit.platform.engine.support .hierarchical.NodeTestTask.lambda$executeRecursively$9( NodeTestTask.java:139 ) at org.junit.platform.engine.support .hierarchical.ThrowableCollector.execute( ThrowableCollector.java:73 ) at org.junit.platform.engine.support .hierarchical.NodeTestTask.executeRecursively( NodeTestTask.java:138 ) at org.junit.platform.engine.support .hierarchical.NodeTestTask.execute( NodeTestTask.java:95 ) at org.junit.platform.engine.support .hierarchical.SameThreadHierarchicalTestExecutorService.submit( SameThreadHierarchicalTestExecutorService.java:35 ) at org.junit.platform.engine.support .hierarchical.HierarchicalTestExecutor.execute( HierarchicalTestExecutor.java:57 ) at org.junit.platform.engine.support .hierarchical.HierarchicalTestEngine.execute( HierarchicalTestEngine.java:54 ) at org.junit.platform.launcher.core.EngineExecutionOrchestrator.execute( EngineExecutionOrchestrator.java:107 ) at org.junit.platform.launcher.core.EngineExecutionOrchestrator.execute( EngineExecutionOrchestrator.java:88 ) at org.junit.platform.launcher.core.EngineExecutionOrchestrator.lambda$execute$0( EngineExecutionOrchestrator.java:54 ) at org.junit.platform.launcher.core.EngineExecutionOrchestrator.withInterceptedStreams( EngineExecutionOrchestrator.java:67 ) at org.junit.platform.launcher.core.EngineExecutionOrchestrator.execute( EngineExecutionOrchestrator.java:52 ) at org.junit.platform.launcher.core.DefaultLauncher.execute( DefaultLauncher.java:114 ) at org.junit.platform.launcher.core.DefaultLauncher.execute( DefaultLauncher.java:86 ) at org.junit.platform.launcher.core.DefaultLauncherSession$DelegatingLauncher.execute( DefaultLauncherSession.java:86 ) at org.junit.platform.launcher.core.SessionPerRequestLauncher.execute( SessionPerRequestLauncher.java:53 ) at com.intellij.junit5.JUnit5IdeaTestRunner.startRunnerWithArgs( JUnit5IdeaTestRunner.java:57 ) at com.intellij.rt.junit.IdeaTestRunner$Repeater$1.execute( IdeaTestRunner.java:38 ) at com.intellij.rt.execution.junit.TestsRepeater.repeat( TestsRepeater.java:11 ) at com.intellij.rt.junit.IdeaTestRunner$Repeater.startRunnerWithArgs( IdeaTestRunner.java:35 ) at com.intellij.rt.junit.JUnitStarter.prepareStreamsAndStart( JUnitStarter.java:232 ) at com.intellij.rt.junit.JUnitStarter.main( JUnitStarter.java:55 ) Caused by: org.springframework.context.annotation.ConflictingBeanDefinitionException: Annotation-specified bean name 'orderServiceImpl' for bean class [hello.core.order.OrderServiceImpl] conflicts with existing, non-compatible bean definition of same name and class [hello.core.OrderServiceImpl] at org.springframework.context.annotation.ClassPathBeanDefinitionScanner.checkCandidate( ClassPathBeanDefinitionScanner.java:349 ) at org.springframework.context.annotation.ClassPathBeanDefinitionScanner.doScan( ClassPathBeanDefinitionScanner.java:287 ) at org.springframework.context.annotation.ComponentScanAnnotationParser.parse( ComponentScanAnnotationParser.java:128 ) at org.springframework.context.annotation.ConfigurationClassParser.doProcessConfigurationClass( ConfigurationClassParser.java:295 ) at org.springframework.context.annotation.ConfigurationClassParser.processConfigurationClass( ConfigurationClassParser.java:249 ) at org.springframework.context.annotation.ConfigurationClassParser.parse( ConfigurationClassParser.java:206 ) at org.springframework.context.annotation.ConfigurationClassParser.parse( ConfigurationClassParser.java:174 ) ... 77 more Process finished with exit code -1
학습하는 분들께 도움이 되고, 더 좋은 답변을 드릴 수 있도록 질문전에 다음을 꼭 확인해주세요. 1. 강의 내용과 관련된 질문을 남겨주세요. 2. 인프런의 질문 게시판과 자주 하는 질문(링크)을 먼저 확인해주세요. (자주 하는 질문 링크: https://bit.ly/3fX6ygx) 3. 질문 잘하기 메뉴얼(링크)을 먼저 읽어주세요. (질문 잘하기 메뉴얼 링크: https://bit.ly/2UfeqCG) 질문 시에는 위 내용은 삭제하고 다음 내용을 남겨주세요. ========================================= [질문 템플릿] 1. 강의 내용과 관련된 질문인가요? (예/아니오) 2. 인프런의 질문 게시판과 자주 하는 질문에 없는 내용인가요? (예/아니오) 3. 질문 잘하기 메뉴얼을 읽어보셨나요? (예/아니오) [질문 내용] AppConfig를 사용할 때는 의존성 주입을 AppConfig가 해줬는데 Component와 Autowired로 bean들을 한번에 컨테이너에 넣을 수 있다는 것은 이해가 갔습니다. 하지만 OrderService와 OrderServiceImpl과 MemberService와 MemberServiceImpl은 어디서 주입되나요? Autowired 의존관계 자동 주입에 이 부분은 나와있지 않아서 질문합니다!
학습하는 분들께 도움이 되고, 더 좋은 답변을 드릴 수 있도록 질문전에 다음을 꼭 확인해주세요. 1. 강의 내용과 관련된 질문을 남겨주세요. 2. 인프런의 질문 게시판과 자주 하는 질문(링크)을 먼저 확인해주세요. (자주 하는 질문 링크: https://bit.ly/3fX6ygx) 3. 질문 잘하기 메뉴얼(링크)을 먼저 읽어주세요. (질문 잘하기 메뉴얼 링크: https://bit.ly/2UfeqCG) 질문 시에는 위 내용은 삭제하고 다음 내용을 남겨주세요. ========================================= [질문 템플릿] 1. 강의 내용과 관련된 질문인가요? (예) 2. 인프런의 질문 게시판과 자주 하는 질문에 없는 내용인가요? (예) 3. 질문 잘하기 메뉴얼을 읽어보셨나요? (예) [질문 내용] 여기에 질문 내용을 남겨주세요. 3:39 쯤에 보면 Overriding bean definition 을 출력하는데 저는 저것 외에도 아무런 로그도 출력하지 않고 그냥 test pass 되네요 logback을 따로등록해야되나요 ? 아니면 스프링 2.x 3.x 차이인지
학습하는 분들께 도움이 되고, 더 좋은 답변을 드릴 수 있도록 질문전에 다음을 꼭 확인해주세요. 1. 강의 내용과 관련된 질문을 남겨주세요. 2. 인프런의 질문 게시판과 자주 하는 질문(링크)을 먼저 확인해주세요. (자주 하는 질문 링크: https://bit.ly/3fX6ygx) 3. 질문 잘하기 메뉴얼(링크)을 먼저 읽어주세요. (질문 잘하기 메뉴얼 링크: https://bit.ly/2UfeqCG) 질문 시에는 위 내용은 삭제하고 다음 내용을 남겨주세요. ========================================= [질문 템플릿] 1. 강의 내용과 관련된 질문인가요? (예/아니오) 2. 인프런의 질문 게시판과 자주 하는 질문에 없는 내용인가요? (예/아니오) 3. 질문 잘하기 메뉴얼을 읽어보셨나요? (예/아니오) [질문 내용] 안녕하세요. 강의 내용을 git으로 private로 커밋하여 다른 강의를 옮겨듣던 기존의 노트북에 내려받았습니다. 내려받은 경우 화면과 같이 애너테이션이 작동하는건지 안하는건지.. 그냥 디스플레이 설정이 다른건지는 잘 모르겠는데 좌측에 .bean 초록색이나 실행버튼이 노출되지 않는 현상은 어떠한 현상일까요..?
학습하는 분들께 도움이 되고, 더 좋은 답변을 드릴 수 있도록 질문전에 다음을 꼭 확인해주세요. 1. 강의 내용과 관련된 질문을 남겨주세요. 2. 인프런의 질문 게시판과 자주 하는 질문(링크)을 먼저 확인해주세요. (자주 하는 질문 링크: https://bit.ly/3fX6ygx) 3. 질문 잘하기 메뉴얼(링크)을 먼저 읽어주세요. (질문 잘하기 메뉴얼 링크: https://bit.ly/2UfeqCG) 질문 시에는 위 내용은 삭제하고 다음 내용을 남겨주세요. ========================================= [질문 템플릿] 1. 강의 내용과 관련된 질문인가요? (예/아니오) 2. 인프런의 질문 게시판과 자주 하는 질문에 없는 내용인가요? (예/아니오) 3. 질문 잘하기 메뉴얼을 읽어보셨나요? (예/아니오) [질문 내용] 여기에 질문 내용을 남겨주세요. 2시간동안 계속 찾아봤는데 뭐가 문지인지 모르겠습니다... nullpoint가 계속 뜨네요ㅕ
강의에서 필드 주입의 경우 일반 테스트 시에는 스프링에 의한 주입이 일어나지 않으니 다른 주입 방법이 있어야 하는데, 방법이 없으므로 권장하지 않는다고 이해했습니다. @Test에서 테스트 시에 테스트 객체 안에서 (static) AppConfig를 만들어서 bean을 정의하고 ApplicationContext에 적용시킨 것이 기억나는데요 제가 이해한 것이 맞다면 test영역에는 스프링 컨테이너가 영향을 끼칠 수 없는 영역인건가요? 그래서 AppConfig를 테스트 영역 안에서 생성하여 적용한 것인가요? 그리고 @SpringBootTest에서는 스프링이 영향을 미치게 되는건가요?