본문 바로가기

스프링 부트16

스프링 gradle database 2개 있는 경우 1 2 3 4 5 6 7 8 9 10 11 12 dependencies { implementation 'org.springframework.boot:spring-boot-starter-data-jpa' implementation 'org.springframework.boot:spring-boot-starter-hateoas' implementation 'org.springframework.boot:spring-boot-starter-web' runtimeOnly 'com.h2database:h2' runtimeOnly 'org.postgresql:postgresql' compileOnly 'org.projectlombok:lombok' testImplementation 'org.springframewor.. 2019. 1. 10.
컨트롤러에서 지정한 세션 값 타임리프에서 읽기 컨트롤러에서는 이렇게 세션에 값을 추가 할 수 있다. 1 2 HttpSession session = (HttpSession)request.getSession(); session.setAttribute("loginUser", loginUser); cs 이제 타임 리프에서 찾아본다. 이렇게 찾으면 된다. 1 2 3 Join Login Logout cs session 이라는 이름의 attribute가 있는 게 아니고. session 쓰고 attribute 이름 쓰면 접근이 된다. 2018. 11. 28.
스프링 부트 jar 파일 Error creating bean with name 'entityManagerFactory' defined in class path resource : Invocation of init method failed 에러 해결 아래 내용을 추가하고 mvn packge 를 해보자. 1 2 3 4 5 javax.xml.bind jaxb-api Colored by Color Scripter cs 스프링 부트이기 때문에 버전은 입력하지 않아도 된다 build 부분은 아래처럼 작성하면 된다. 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 org.springframework.boot spring-boot-maven-plugin com.example.postgresdemo.PostgresDemoApplication//메인 클래스 위치 true true com.example.postgresdemo//메인 클래스가 있는 패키지 이름 Colored by Color Scripter cs 2018. 11. 23.
spring boot 1.5.17 버전 jpa 로 데이터 베이스 조작 mysql 스프링으로 웹 개발을 할 때 DB에 어떻게 접근하는게 좋을까 몇가지 방법이 있다. 1. 직접 자바 코드를 작성해서 DB에 접근 2. ORM을 사용하는 방법 1번은 권장하지 않는다. 접근을 수월하게 해주는 ORM 이라는 도구가 있기 때문이다. 쿼리를 매핑해주는 Mybatis 를 쓰기도 한다. DB 조작시 많이 사용되는 것은 3가지가 있다. 1. Mybatis - xml 을 활용해서 쿼리를 매핑한다. 2. JPA - ORM 으로써 자바 코드로 DB 조작을 더 수월하게 할 수 있게 한다. 3. Hibernate - ORM 으로써 자바 코드로 DB 조작을 더 수월하게 할 수 있게 한다. 사실 Mybatis 는 우리나라에서만 많이 쓴다. 그것도 좋지 않은 SI 에서만. 아무튼 spring boot 에서 많이 쓰이.. 2018. 11. 15.
Spring boot Reference Guide 6 Spring boot Reference Guide 6 스프링 부트 패키지 이름에 관한 이야기 패키지를 만들지 않고 바로 클래스를 생성하면 default 패키지가 생성됩니다. 스프링 부트 에서는 이렇게 default 패키지에 클래스를 생성하는 것을 권장하지 않습니다. 스프링 부트를 사용해서 개발하다 보면 @Componentscan을 통해서 특정 패키지에 위치한 파일을 읽어야 할 때가 있는데 default 는 패키지에 이름을 지정하지 않았기 때문에 문제가 됩니다. -프로젝트를 생성하면 나타나는 @SpringBootApplication에 관한 이야기 @SpringBootApplication 애너테이션은 @Configuration , @EnableAutoConfiguration , @ComponentScan 3.. 2018. 3. 29.