- 그레이들 버전 안내 : 4.4 버전 사용 (책 출간 시점)
- 최신 버전 사용시 빌드 파일을 최신 버전에 맞게 수정해야 함
madvirus / spring5fs Goto Github PK
View Code? Open in Web Editor NEW스프링5 프로그래밍 입문 책 소스 코드
스프링5 프로그래밍 입문 책 소스 코드
중요한 내용은 아니지만 list, version, info등의 명령어를 추가하면서 해당 함수에도 내용을 추가하는 게 좋을 것 같아요.
Exception in thread "main" org.springframework.jdbc.CannotGetJdbcConnectionException: Failed to obtain JDBC Connection; ~
과 같은 에러가 발생하시는 분들 제 경우에는 mysql-connector-java 버전을 8.0.17로 변경한 뒤,
my.cnf(Windows 이용자의 경우 my.ini) 파일에서 Timezone을 KST로 변경해 주고 mysql을 재시작 했더니 해결되었습니다.
같은 문제를 겪는 분들에게 도움이 되었으면 좋겠습니다!
참고 :
https://victorydntmd.tistory.com/321
https://offbyone.tistory.com/318
책에서 gradle을 최신 버전으로 다운로드하라고 했지만
저는 오류가 났습니다.
[오류메시지 중 일부]
Could not find method compile() for arguments [org.springframework:spring-context:5.0.2.RELEASE] on object of type
그래서 gradle을 다시 4.4로 맞춰 설치해봤더니 잘되네요.
만약 안되셔서 찾아오신 분들을 위해 글 남깁니다.
깃헙 소스 코드 그대로 작성 후 래퍼 파일을 생성하려고 하니 실패가 떠서 해결한 뒤 글을 작성합니다.
예전에는 원하는 gralde 버전을 명시했던 부분을 이제는 설정을 하지 않아도 된다고 합니다.
참고 : https://kwonnam.pe.kr/wiki/gradle/wrapper
task wrapper(type: Wrapper) {
gradleVersion = '1.6' // 원하는 Gradle 버전 명시
}
수정된 부분 확인하시고 참고하세요~
apply plugin: 'java'
sourceCompatibility = 1.8
targetCompatibility = 1.8
compileJava.options.encoding = "UTF-8"
repositories {
mavenCentral()
}
dependencies {
compile 'org.springframework:spring-context:5.0.2.RELEASE'
}
task wrapper(type: Wrapper){
gradleVersion = '4.4'
}
apply plugin: 'java'
sourceCompatibility = 1.8
targetCompatibility = 1.8
compileJava.options.encoding = "UTF-8"
repositories {
mavenCentral()
}
dependencies {
compile 'org.springframework:spring-context:5.0.2.RELEASE'
}
제가 접한 에러 메시지는 다음과 같습니다.
FAILURE: Build failed with an exception.
* Where:
Build file 'C:\spring5fs\sp5-chap02\build.gradle' line: 15
* What went wrong:
A problem occurred evaluating root project 'sp5-chap02'.
> Cannot add task 'wrapper' as a task with that name already exists.
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.
* Get more help at https://help.gradle.org
Deprecated Gradle features were used in this build, making it incompatible with Gradle 7.0.
Use '--warning-mode all' to show the individual deprecation warnings.
See https://docs.gradle.org/6.9.3/userguide/command_line_interface.html#sec:command_line_warnings
책에 적힌 build.gradle로 build wrapper를 실행하면 Cannot add task 'wrapper' as a task with that name already exists
라는 메세지로 빌드가 실패합니다. 원인을 살펴보니 아래와 같다고 해서 to-be로 제안드립니다!
Overriding built-in tasks deprecated in 4.8 now produces an error.
참고 글
as-is
task wrapper(type: Wrapper) {
gradleVersion = '4.4'
}
to-be
wrapper {
gradleVersion = '4.4'
}
정보: Refreshing org.springframework.context.annotation.AnnotationConfigApplicationContext@59f99ea: startup date [Thu Feb 03 21:22:49 KST 2022]; root of context hierarchy
Exception in thread "main" java.lang.IllegalStateException: Cannot load configuration class: chap02.AppContext
at org.springframework.context.annotation.ConfigurationClassPostProcessor.enhanceConfigurationClasses(ConfigurationClassPostProcessor.java:416)
at org.springframework.context.annotation.ConfigurationClassPostProcessor.postProcessBeanFactory(ConfigurationClassPostProcessor.java:254)
at org.springframework.context.support.PostProcessorRegistrationDelegate.invokeBeanFactoryPostProcessors(PostProcessorRegistrationDelegate.java:284)
at org.springframework.context.support.PostProcessorRegistrationDelegate.invokeBeanFactoryPostProcessors(PostProcessorRegistrationDelegate.java:128)
at org.springframework.context.support.AbstractApplicationContext.invokeBeanFactoryPostProcessors(AbstractApplicationContext.java:693)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:531)
at org.springframework.context.annotation.AnnotationConfigApplicationContext.<init>(AnnotationConfigApplicationContext.java:88)
at chap02.Main2.main(Main2.java:9)
Caused by: java.lang.ExceptionInInitializerError
at org.springframework.context.annotation.ConfigurationClassEnhancer.newEnhancer(ConfigurationClassEnhancer.java:122)
at org.springframework.context.annotation.ConfigurationClassEnhancer.enhance(ConfigurationClassEnhancer.java:110)
at org.springframework.context.annotation.ConfigurationClassPostProcessor.enhanceConfigurationClasses(ConfigurationClassPostProcessor.java:405)
... 7 more
Caused by: org.springframework.cglib.core.CodeGenerationException: java.lang.reflect.InaccessibleObjectException-->Unable to make protected final java.lang.Class java.lang.ClassLoader.defineClass(java.lang.String,byte[],int,int,java.security.ProtectionDomain) throws java.lang.ClassFormatError accessible: module java.base does not "opens java.lang" to unnamed module @2e3fc542
at org.springframework.cglib.core.ReflectUtils.defineClass(ReflectUtils.java:464)
at org.springframework.cglib.core.AbstractClassGenerator.generate(AbstractClassGenerator.java:336)
at org.springframework.cglib.core.AbstractClassGenerator$ClassLoaderData$3.apply(AbstractClassGenerator.java:93)
at org.springframework.cglib.core.AbstractClassGenerator$ClassLoaderData$3.apply(AbstractClassGenerator.java:91)
at org.springframework.cglib.core.internal.LoadingCache$2.call(LoadingCache.java:54)
at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
at org.springframework.cglib.core.internal.LoadingCache.createEntry(LoadingCache.java:61)
at org.springframework.cglib.core.internal.LoadingCache.get(LoadingCache.java:34)
at org.springframework.cglib.core.AbstractClassGenerator$ClassLoaderData.get(AbstractClassGenerator.java:116)
at org.springframework.cglib.core.AbstractClassGenerator.create(AbstractClassGenerator.java:291)
at org.springframework.cglib.core.KeyFactory$Generator.create(KeyFactory.java:221)
at org.springframework.cglib.core.KeyFactory.create(KeyFactory.java:174)
at org.springframework.cglib.core.KeyFactory.create(KeyFactory.java:153)
at org.springframework.cglib.proxy.Enhancer.<clinit>(Enhancer.java:73)
... 10 more
Caused by: java.lang.reflect.InaccessibleObjectException: Unable to make protected final java.lang.Class java.lang.ClassLoader.defineClass(java.lang.String,byte[],int,int,java.security.ProtectionDomain) throws java.lang.ClassFormatError accessible: module java.base does not "opens java.lang" to unnamed module @2e3fc542
at java.base/java.lang.reflect.AccessibleObject.checkCanSetAccessible(AccessibleObject.java:354)
at java.base/java.lang.reflect.AccessibleObject.checkCanSetAccessible(AccessibleObject.java:297)
at java.base/java.lang.reflect.Method.checkCanSetAccessible(Method.java:199)
at java.base/java.lang.reflect.Method.setAccessible(Method.java:193)
at org.springframework.cglib.core.ReflectUtils$1.run(ReflectUtils.java:61)
at java.base/java.security.AccessController.doPrivileged(AccessController.java:569)
at org.springframework.cglib.core.ReflectUtils.<clinit>(ReflectUtils.java:52)
at org.springframework.cglib.core.KeyFactory$Generator.generateClass(KeyFactory.java:243)
at org.springframework.cglib.core.DefaultGeneratorStrategy.generate(DefaultGeneratorStrategy.java:25)
at org.springframework.cglib.core.AbstractClassGenerator.generate(AbstractClassGenerator.java:329)
... 22 more
Cannot load configuration class: chap02.AppContext
위 부분이 주된 내용인거 같은데
Maven 프로젝트의 Main.java를 실행하는데 위와 같은 오류가 발생합니다.
왜 그런지 알 수 있을까요?
apply plugin: 'java'
sourceCompatibility = 1.8
targetCompatibility = 1.8
compileJava.options.encoding = "UTF-8"
repositories {
mavenCentral()
}
// compile은 오류가 발생해서 implementation으로 변경
dependencies {
implementation 'org.springframework:spring-context:5.0.2.RELEASE'
}
wrapper {
gradleVersion = '7.3.3'
}
로그인 테스트를 하는 중인데 DB에서 데이터를 가져와서 검증을 하는 거 같지 않습니다.
다른 분들도 그러신지 궁금하네요ㅠㅠ
예제 코드대로 하면 "Circular view path" exceptions 이 발생하는군요
원인은 view의 이름과 path가 같으면 발생하는 것 같습니다
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.