자바와 스프링 부트로 생애 최초 서버 만들기, 누구나 쉽게 개발부터 배포까지! [서버 개발 올인원 패키지]
dependencies { implementation 'org.springframework.boot:spring-boot-starter-data-jpa' implementation 'org.springframework.boot:spring-boot-starter-web' runtimeOnly 'com.h2database:h2' runtimeOnly 'mysql:mysql-connector-java:8.3.0' testImplementation 'org.springframework.boot:spring-boot-starter-test' } 위와 같이 dependencies를 설정했고 밑은 application.yml입니다. spring: datasource: url: "jdbc:mysql://loca lhost/library" username: "root" password: "비밀번호" driver-class-name: com.mysql.cj.jdbc.Driver 비밀번호는 알아서 설정했습니다. 오류가 생겨서 dependencies에서 runtimeOnly 'mysql:mysql-connector-java:8.3.0'로 설정했습니다. 밑에는 에러 표시입니다. Execution failed for task ':LibraryAppApplication.main()'. > Could not resolve all files for configuration ':runtimeClasspath'. > Could not find mysql:mysql-connector-java:8.3.0. Required by: project : Possible solution: - Declare repository providing the artifact, see the documentation at https://docs.gradle.org/current/userguide/declaring_repositories.html > Task :LibraryAppApplication.main() FAILED Execution optimizations have been disabled for task ':LibraryAppApplication.main()' to ensure correctness due to the following reasons: - Type 'org.gradle.api.tasks.JavaExec' property 'classpath' cannot be resolved: Could not resolve all files for configuration ':runtimeClasspath'. Reason: An input file collection couldn't be resolved, making it impossible to determine task inputs. Please refer to https://docs.gradle.org/7.5/userguide/validation_problems.html#unresolvable_input for more details about this problem. Execution failed for task ':LibraryAppApplication.main()'. > Could not resolve all files for configuration ':runtimeClasspath'. > Could not find mysql:mysql-connector-java:8.3.0. Required by: project : Possible solution: - Declare repository providing the artifact, see the documentation at https://docs.gradle.org/current/userguide/declaring_repositories.html Could not find mysql:mysql-connector-java:8.3.0. Required by: project : Search in build.gradle files 뭐가 에러인가요..? 만약 Runtimeonly뒤에 version을 따로 기입하지 않는다면, Caused by: com.mysql.cj.exceptions.CJCommunicationsException: Communications link failure 라는 에러가 뜹니다.
[질문 내용] 여기에 질문 내용을 남겨주세요.안녕하세요. 선생님께서 컴파일 완료된 것들은 out 폴더에 보인다고 하셨는데 hellojava랑 main만 보이고 나머지도 모두 컴파일 완료 했는데 out 폴더에서 보이지 않습니다.왜 그런건가요?? 그리고 out 폴더에서 보이지 않는다면 문제가 있을까요?
[코드팩토리] [초급] Flutter 3.0 앱 개발 - 10개의 프로젝트로 오늘 초보 탈출!
- 학습 관련 질문을 남겨주세요. 상세히 작성하면 더 좋아요! - 먼저 유사한 질문이 있었는지 검색해보세요. - 서로 예의를 지키며 존중하는 문화를 만들어가요. - 잠깐! 인프런 서비스 운영 관련 문의는 1:1 문의하기를 이용해주세요. 코드팩토리 디스코드 https://bit.ly/3HzRzUM Flutter 강의를 구매하시면 코드팩토리 디스코드 서버 플러터 프리미엄 채널에 들어오실 수 있습니다! 디스코드 서버에 들어오시고 저에게 메세지로 강의를 구매하신 이메일을 보내주시면 프리미엄 채널에 등록해드려요! 프리미엄 채널에 들어오시면 모든 질의응답 최우선으로 답변해드립니다!
- 학습 관련 질문을 남겨주세요. 상세히 작성하면 더 좋아요! - 먼저 유사한 질문이 있었는지 검색해보세요. - 서로 예의를 지키며 존중하는 문화를 만들어가요. - 잠깐! 인프런 서비스 운영 관련 문의는 1:1 문의하기를 이용해주세요. [내부영역:응용서비스 구현(어플리케이션 헥사곤)-InputPort구현,아우터 포트 정의]강의에서 음성이 불명확하고, 코드 포커스로 확대하신것같은데 잘린부분(클래스 명, 어노테이션 등)이 많아요
DispatcherServlet 에 대해 개인적으로 공부를 하다 아래와 같은 사진이 많이 보여서 처음에는 DispatcherServlet 에서 의존성 주입을 받을 때 Servlet WebApplicationContext Container 에서 주입받고 없으면 Root WebApplicationContext 까지 검색하여 주입하는 것으로 이해를 했습니다. 그리고 Root WebApplicationContext 에는 웹과 관련 없는 객체들이 등록하여 사용한다고 하여 그런줄 알았는데 실제로 디버깅을 해보니 SpringApplication.run 메서드 내에서 createApplicationContext 메서드가 호출되어 AnnotationConfigServletWebServerApplicationContext 객체가 생성된 후, localhost:8080/xxx 로 HTTP Request 를 보내니 FrameworkServlet 의 initServletBean 메서드에서 initWebApplicationContext 메서드를 호출해서 Root WebApplicationContext 를 가져와서 FrameworkServlet 의 webApplicationContext 에 참조를 저장하는데 이렇게 되면 사진에서의 Root ApplicationContext 와 Servlet WebApplicationContext 가 동일한 객체인걸로 생각이 되는데 실제로 두 객체가 같은 것인지, 아니면 뭔가 다른 무언가를 제가 하지 않아서 같은 참조를 가지는 건지 궁금하여 질문남깁니다!
DEEP DIVE : 싱글톤 패턴을 구현하는 7가지 방법 #2 ★★☆ 강의 volatile 설명에서 알려주신 자바 코드와 동일하게 Kotlin 코드를 작성했습니다. class Test2 { private var flag = true fun test() { Thread { var cnt = 0 while (flag) { cnt++ Thread.sleep(100) println(cnt) } println("Thread1 finished") }.start() Thread { Thread.sleep(100) println("flag to false") flag = false }.start() } } 이 코드를 실행하면, flag가 바뀌는 즉시 첫 번째 쓰레드가 멈춥니다. 이유가 궁금해서 자바로 디컴파일된 코드를 확인해봤고, Thread1에서 flag를 확인할 때 Test2.this.flag와 같이 접근하는 것을 발견했습니다. ClassName.this 가 무엇인지 궁금합니다. 자바의 정석 책에 해당 내용은 없고, 구글에 검색해봤는데, 유의미한 답변으로 아래 글만 발견했습니다. Within an instance method or a constructor, this is a reference to the current objec t — the object whose method or constructor is being called. You can refer to any member of the current object from within an instance method or a constructor by using this. https://stackoverflow.com/questions/4080868/using-this-with-class-name/46091971#46091971
https://drive.google.com/drive/folders/1unulH1E9G7a--c4InEpy_4NwIEKrvH4b?usp=sharing 회원가입 로직 테스트 오류가 납니다. 필요:hello.demo.domain.Member@f48a080 실제 :hello.demo.domain.Member@1d3a03fe <클릭하여 차이점 확인> org.opentest4j.AssertionFailedError: expected: hello.demo.domain.Member@f48a080 but was: hello.demo.domain.Member@1d3a03fe at java.base/jdk.internal.reflect.DirectConstructorHandleAccessor.newInstance(DirectConstructorHandleAccessor.java:62)
build.gradle에 웹 라이브러리 추가하고 dependencies { implementation 'org.springframework.boot:spring-boot-starter' implementation 'jakarta.inject:jakarta.inject-api:2.0.1' //web 라이브러리 추가 implementation 'org.springframework.boot:spring-boot-starter-web' CoreApplicaton을 돌렸더니, 아래와 같은 오류 메세지가 뜹니다. 대충 어떤 오류인지는 알겠는데.....어떻게 찾아서 고쳐야 할지는 모르겠네요? Error starting ApplicationContext. To display the condition evaluation report re-run your application with 'debug' enabled. Parameter 0 of constructor in hello.core.member.MemberServiceImpl required a single bean, but 2 were found: - memoryMemberRepository: defined in file [C:\SpringBoot\core\out\production\classes\hello\core\member\MemoryMemberRepository.class] - memberRepository: defined by method 'memberRepository' in class path resource [hello/core/AppConfig.class] This may be due to missing parameter name information Action: Consider marking one of the beans as @Primary, updating the consumer to accept multiple beans, or using @Qualifier to identify the bean that should be consumed Ensure that your compiler is configured to use the '-parameters' flag. You may need to update both your build tool settings as well as your IDE.
DEEP DIVE : 싱글톤 패턴을 구현하는 7가지 방법 #2 ★★☆ 챕터에서 5. 정적 멤버와 Lazy Holder(중첩 클래스)를 이용한 방법으로 아래 코드를 설명해주셨는데요 public class Singleton { private static class singleInstanceHolder { private static final Singleton INSTANCE = new Singleton(); } public static Singleton getInstance() { return singleInstanceHolder.INSTANCE; } } 생성자를 private으로 막지 않으면 싱글턴 인스턴스를 만든 이유가 없지 않나요? 싱글턴이 필요하지 않을 때는 생성자 호출로 생성한 후, 더 이상 쓰지 않을 때 GC가 회수하게 하다, 싱글턴이 필요한 순간에 생성하는 건가요? public class Main { public static void main(String[] args) { Singleton instance = new Singleton(); // 싱글턴이 필요하지 않으면 직접 호출하기 Singleton singleton1 = Singleton.getInstance(); // 싱글턴이 필요한 순간에 싱글턴 객체 생성하기? } }
http://boj.kr/3508e81686454e2ea04b64d2c4a3ba94 풀이법과 조금 다르지만 같은 원리로 풀었습니다 그런데 http://boj.kr/9f02c3d4d7b14d9eb585cb7dabfc6d2a 이건 두번째로 생각해본 풀이인데 이 코드는 틀렸다고 나옵니다. 두 코드의 차이점은 매개변수 y (지수부분)가 홀수일 때 첫번째 코드는 go(y-1) , go(1) 을 해서 한쪽부분을 짝수로 만들어준 것이고 두번째 코드는 go(y/2) ,go(y/2) ,go(1) 로 2로 나눠주면서 홀수라서 남는 부분을 곱해주는 방식입니다. 모듈러 공식이 (a * b) % c = ((a%c) *(a%c))%c 라고 하면 (a*b*c)%c 도 같이 적용되어야 하는게 아닌가 싶어서 질문드렸습니다!
#include <stdio.h> int main() { //freopen("input.txt","rt",stdin); int n,abs,left,right,res=1; scanf("%d",&n); int a[n]={0,}; scanf("%d",&left); for(int i=1;i<n;i++){ scanf("%d", &right); abs=(right-left>0)?right-left:left-right; a[abs]=1; left=right; } for(int i=1;i<n;i++){ if(a[i]!=1) res=0; } if(res==1){ printf("YES\n"); } else{ printf("NO\n"); } return 0; } 강의 듣기 전 스스로 짠 코드입니다. 채점결과 마지막 케이스만 이렇게 출력되는데 다섯번째 파일만 따로 돌려봐도 에러없이 종료되어서 원인을 잘 모르겠습니다ㅠㅠ