일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | 4 | |||
5 | 6 | 7 | 8 | 9 | 10 | 11 |
12 | 13 | 14 | 15 | 16 | 17 | 18 |
19 | 20 | 21 | 22 | 23 | 24 | 25 |
26 | 27 | 28 | 29 | 30 | 31 |
- ReactJS
- elasticsearch
- Web Server
- 요리
- MySQL
- docker
- tool
- jsp
- springboot
- Git
- JPA
- laravel
- it
- db
- Spring Boot
- redis
- php
- Oracle
- Design Patterns
- Gradle
- java
- Spring
- devops
- jenkins
- javascript
- linux
- IntelliJ
- AWS
- ubuntu
- 맛집
- Today
- Total
목록Java (237)
아무거나
버티컬바 2개로 구분이 되어있는 문자열일 경우에 split 함수를 이용하여 분리해보자. public class ExampleMain { public static void main(String[] args) { String testStr = "bkjeon1614||안녕하세요"; String[] testArr = testStr.split("||"); System.out.println(testArr[0]); System.out.println(testArr[1]); System.out.println("------------------------------"); String[] testArr2 = testStr.split("\\|\\|"); System.out.println(testArr2[0]); System...
Hexadecimal: 컴퓨터 분야에서 숫자를 표현하기 위해 사용하는 진법 방식중에 하나이다. 이것은 Hexadecimal 또는 Hex라고 불린다.-> 16진수 (16을 기수로 하는 번호체계를 말한다.) 이러한 헥사코드를 Java를 이용하여 문자열 -> Hex, Hex -> 문자열을 변환하는 방법을 알아보자. import java.io.UnsupportedEncodingException; import javax.xml.bind.DatatypeConverter; import org.apache.commons.codec.DecoderException; import org.apache.commons.codec.binary.Hex; public class ExampleMain { public static voi..
[MacOS] 1. 원하는 jar 파일을 다운받는다. 2. IntelliJ의 File -> Project Structure... 을 클릭하면 아래 이미지와 같은 화면이 표시된다. 2. Modules -> 프로젝트 -> 오른쪽 탭중 Dependencies 클릭하면 아래와 이미지와 같은 화면이 표시된다. 3. 하단에 "+"버튼을 클릭하여(=JARs or directories...) 다운받았던 jar파일을 선택한다. 그리고 적용시키자. 4. 적용하게되면 좌측에 External Libraries를 확인하면 등록되어있는것을 볼 수 있다.
Spring Security를 적용하게되면 로그인을 안할 시에 로그인 페이지(/login)으로 이동시키는 기능을 적용해 놓았다. 그런데 만약 로그인 필요없이 특정 path에 접근하고 싶을때 Security Config 파일에서 아래와 같이 코드를 적용시켜보자.(ex: css,js 및 특정 api(=/api/test)에 대해 허용해놓음) import javax.sql.DataSource; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.annotation.Configuration; import org.springframework.security.config.annotation.au..
[준비]해당 포스트는 IntelliJ IDE기반이므로 https://bkjeon1614.tistory.com/56을 참고하여 먼저 IntelliJ와 tomcat을 연동하자. 1. build.gradle dependencies 추가dependencies { ... providedRuntime 'org.springframework.boot:spring-boot-starter-tomcat’ ... } 2. SpringBootServletInitializer에 configure추가 import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; import org..
예를 들어 아래와 같은 Mapper Method와 User Entity가 존재한다고 가정하자. [User.java]@Getter @Setter public class User { private int id; private String password; private String passwordConfirm; private String loginId; private String userName; private int active; private String accessToken; } [UserMapper.java]@Transactional int setUserInfo(@Param("param") User param); setUserInfo를 id로 매핑되어있는 Mapper.xml 파일을 확인하면 아래와 같..
Spring Boot 기준으로 작업하는 도중에 실행되는 SQL Log를 직접 콘솔에서 확인하고 싶었다.그래서 logback.xml에서 아래와 같이 설정하면 된다. [logback.xml]level을 DEBUG로 해놓아야지만 로그가 출력된다. INFO로 설정하면 출력되지 않는다.logger name은 출력하고 싶은 패키지 경로를 지정하면 된다. ... * 출력은 아래와 같이 패키지 경로와 메소드명, 그리고 쿼리문과 파라미터 및 개수 등이 출력된다.
개발을 하던 도중에 다량의 데이터를 한번에 update 할 시에는 무척 오래걸려서 db옵션을 수정하는 등 조치를 취하는 경우가 있다. 그래서 단 건(ex: 10000 건) 정도로 여러번 업데이트 하는 방법으로 로직을 변경하였고 while문을 이용하여 change개수가 0일 경우에는 break로 빠져나오게끔 만들었다. 그러나 mybatis에서 change개수가 계속 0으로만 return되는 문제가 발생하였다. 확인해보니 설정파일 즉, db접속 url parameter에 아래와 같이 추가하자. jdbc:mysql://127.0.0.1:3306/test_db?useSSL=false&characterEncoding=utf8&useAffectedRows=true 위의 useAffectedRows=true 로 옵션..
스프링 부트에서 테스트 코드를 작성할 때 간단하게 기술한것이다. // 버전: 2.0.6 testCompile('org.springframework.boot:spring-boot-starter-test') import com.wmp.admin.category.entity.VendorCategoryMap; import com.wmp.admin.category.mapper.CategoryMapMapper; import com.wmp.admin.category.mapper.CategoryMapRequireMapper; import java.time.LocalDateTime; import org.junit.Test; import org.junit.runner.RunWith; import org.springfram..
Mybatis 작업도중에 Invalid bound statement (not found) 에러가 발생했을때를 알아보자.자주 실수하여 발생하는 문제는 아래와 같다 - Mapper Interface와 Mapping되는 .xml 파일에 오타가 있을 경우(ex: Mapper Interface에 선언한 메서드명과 .xml에 매핑하는 id값과 일치하지 않을 때)- classpath에 경로가 잘못될 경우 [ex]mybatis: mapper-locations: classpath:mapper/**/*.xml 보통 개발을 하면서 자주하는 실수들이므로 주의해서 작성하자.