본문 바로가기

자바14

[Java] 자바 cannot make a static reference to the non-static field 오류 1. 원인 참조할 수 없는 이유는 컴파일 순서에서 찾을 수 있다. 다른 멤버보다 static 멤버가 먼저 컴파일되기 때문에, static 멤버의 컴파일 시점에서는 static이 아닌 메서드나 필드는 정의되지 않았기 때문이다. 2. 해결방법 - 모든 메서드나 필드를 static 멤버로 바꾸기 - 클래스의 객체를 직접 생성해서(Abc abc = new Abc();) 접근 출처: https://wookoa.tistory.com/80 3. 추가 궁금증 @RequestMapping처럼 url과 연결되는 메서드는 어떻게 static이 아니어도 (객체 생성을 하지 않아도) 웹에서 잘 작동할 수 있을까? => static이 안 붙은 메서드는 인스턴스 메서드이기 때문에 객체 생성이 필요하다. 그러나 객체 생성을 하지 않.. 2022. 10. 12.
[Java] 자바 Map 차이점 1. hashmap - null 허용 linkedhashmap - null 허용하지 않음 출처 : https://wooktae.tistory.com/38 2. HashMap map = new HashMap(); Map map = new HashMap(); hashmap으로 객체 사용하면 hashmap밖에 못 쓰는데 map으로 hashmap 쓰면 map으로 수정되어도 코드 수정 안 해도 돼서 유지보수성이 뛰어나다고 함 출처 : https://juyoungit.tistory.com/587 + ArrayList 안에 HashMap 넣기 https://m.blog.naver.com/ddakshe2/140176655437 2022. 10. 11.
[Java/Spring] 자바 sql 오류 java.sql.SQLSyntaxErrorException: Incorrect number of arguments 해결 방법 오류 : Caused by: java.sql.SQLSyntaxErrorException: Incorrect number of arguments for FUNCTION [FUNCTION name]; expected 2, got 3 원인 및 해결 : 해당 FUNCTION에 매개변수를 2개만 넘겨야 하는데 3개 넘겨서 나는 오류다. 개수 맞춰주면 해결됨. 2022. 10. 7.
[Java] 자바 열거 enum 활용 name() 열거 객체의 문자열 리턴 Season season = Season.SPRING; String name = season.name(); // "SPRING" values() 열거 타입의 모든 열거 객체들을 배열로 만들어 리턴 Season[] seasons = Season.values(); for(Season season : seasons) { System.out.println(season); } 출처: https://itmining.tistory.com/149 + enum 클래스를 Map 스타일로 enumMap // enum 클래스의 소스 public enum Category { image("image", "이미지"), audio("audio", "오디오"), video("video", "비디오.. 2022. 9. 30.
[Java/Eclipse/Spring] 자바 버젼 업그레이드 시 오류 ASM ClassReader failed to parse class file JDK1.7 -> JDK1.8 업그레이드 Spring 버젼 3.2.3.RELEASE 오류 메시지 : ASM ClassReader failed to parse class file - probably due to a new Java class file version that isn't supported yet 원인 : 스프링 버젼이 낮아 1.8 버젼의 클래스 파일을 파싱해주지 못함. 해결방법 : 스프링 버젼을 4.x로 업그레이드 if you want run your code with Java 8, you need to use a recent Spring 4.0 version. https://stackoverflow.com/questions/22730801/java-se-spring-data-hibernate.. 2022. 6. 2.