keystore파일, 즉 주로 확장자가 jks 끝나는 인증서 파일로 tomcat에서 사용한다고 하면 전달하는 파일이다.

그런데, 사이트에서 직접 구매한 ssl keystore파일은 비밀번호가 부자연스럽고, 어려워서 변경하기를 원한다.

 

결론은 구글링해서 나온 검색어를 제대로 이해하지 못하면 삽질을 하게된다.

아래의 순서대로 그대로 진행하면 적어도 삽질의 횟수를 조금은 줄일수 있을것으로 보인다.

 

1.keystore password(키 저장소 비밀번호) 변경
키 저장소 파일명 : mydomaintest.com.jks
alias 명 : mydomaintest.com
최초 발급받은 비번 : 12345
변경할 비밀번호 : new12345
keytool -storepasswd -new new12345 -keystore mydomaintest.com.jks
키 저장소 비밀번호 입력: 12345 ( 초기 ssl 인증서 업체로부터 전달받은 비밀번호 )

2.keypass password( 키패스 비밀번호 ) 변경
keytool -keypasswd -alias mydomaintest.com -new new12345 -keystore mydomaintest.com.jks
키 저장소 비밀번호 입력: new12345 ( 위에서 변경한 비밀번호 입력 )
<mydomaintest.com>에 대한 키 비밀번호를 입력하십시오. 12345 ( 최초 발급시 발급받은 비밀번호 )

 

 

 



eclipse나 sts에서 Gradle프로젝트를 import하거나 할때 Project and External Dependencies가 나오지 않는 경우가 종종 발생한다.

이전 Maven프로젝트에서 의존성라이브러인 Maven Dependencies가 나오지 않는 경우와 유사한것이다.

구글링을 통해 이런저런 방법을 사용해 보았으나 딱히 적용이 안되어서 본인의 경우에는 프로젝트 루트에 위치한 .project 파일을 직접 수정해서 살려냈다. 

 

위 파일은 Ctrl + Shift + r 을 눌러 파일명으로 검색해서 찾는것이 빠르다. 숨겨진 파일이고 Project Explorer에 나오지 않음.

아래는 일반적인 gradle project의 .project 파일형태이다.

<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
	<name>testGradle</name>
	<comment>test</comment>
	<projects></projects>
	<buildSpec>
		<buildCommand>
			<name>org.eclipse.jdt.core.javabuilder</name>
			<arguments>
			</arguments>
		</buildCommand>
		<buildCommand>
			<name>org.eclipse.wst.validation.validationbuilder</name>
			<arguments>
			</arguments>
		</buildCommand>
		<buildCommand>
			<name>org.eclipse.buildship.core.gradleprojectbuilder</name>
			<arguments>
			</arguments>
		</buildCommand>
		<buildCommand>
			<name>org.springframework.ide.eclipse.boot.validation.springbootbuilder</name>
			<arguments>
			</arguments>
		</buildCommand>
	</buildSpec>
	<natures>
		<nature>org.eclipse.jdt.core.javanature</nature>
		<nature>org.eclipse.wst.common.modulecore.ModuleCoreNature</nature>
		<nature>org.eclipse.jem.workbench.JavaEMFNature</nature>
		<nature>org.eclipse.buildship.core.gradleprojectnature</nature>
		<nature>org.eclipse.wst.jsdt.core.jsNature</nature>
		<nature>net.harawata.mybatipse.MyBatisNature</nature>
	</natures>
</projectDescription>

아래는 Project and External Dependencies 가 나오지 않을때의 .project파일이다.

 

<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
	<name>testGradle</name>
	<comment>test</comment>
	<projects></projects>
	<buildSpec>
		<buildCommand>
			<name>org.eclipse.jdt.core.javabuilder</name>
			<arguments>
			</arguments>
		</buildCommand>
		<buildCommand>
			<name>org.eclipse.wst.common.project.facet.core.builder</name>
			<arguments>
			</arguments>
		</buildCommand>
		<buildCommand>
			<name>org.eclipse.wst.validation.validationbuilder</name>
			<arguments>
			</arguments>
		</buildCommand>
		<buildCommand>
			<name>org.eclipse.buildship.core.gradleprojectbuilder</name>
			<arguments>
			</arguments>
		</buildCommand>
		<buildCommand>
			<name>org.springframework.ide.eclipse.boot.validation.springbootbuilder</name>
			<arguments>
			</arguments>
		</buildCommand>
	</buildSpec>
	<natures>
		<nature>org.eclipse.jdt.core.javanature</nature>
		<nature>org.eclipse.wst.common.project.facet.core.nature</nature>
		<nature>org.eclipse.wst.common.modulecore.ModuleCoreNature</nature>
		<nature>org.eclipse.jem.workbench.JavaEMFNature</nature>
		<nature>org.eclipse.buildship.core.gradleprojectnature</nature>
		<nature>org.eclipse.wst.jsdt.core.jsNature</nature>
		<nature>net.harawata.mybatipse.MyBatisNature</nature>
	</natures>
</projectDescription>

 

예상하기론 Project Properties의 Buidlers에 나오는 목록을 나타내는 파일인데 여기서 Gradle과 상관없는 project.facet.core.nature형태가 추가가 되는 경우이다. 

 

위 Builders에서 Facet Project Validation Builder를 Remove하고 싶은데 버튼이 비활성화가 되어 제거할수 없다. checkbox해제를 해도 해결되지 않는다. 

그래서 결론은 .project파일을 직접 수정해서 이 프로젝트가 Gradle 프로젝트라는 것을 eclipse에게 알려줘야 하는것으로 판단된다. 

결론은 .proejct파일을 열어서 facet 부분을 제거하고 새로고침하면  Project and External Dependencies 항목이 정상적으로 나온다는 사실. 

 



Spring Boot 개발 적용 팁

Posted 2020. 9. 3. 00:25

기존 SpringFramework 3.x, 4.x를 사용하다가 Spring Boot로 갈아타면서 활용한 개발적용 팁

 

I. CustomListener class 적용

이전의 Servlet 기반 web.xml 에 정의하거나 @WebListener 사용하여 WAS 구동시 listener class를 적용하는 방법을 Spring Boot에 적용하는 방법

 

예) 이전적용 예 1.

  <listener>
    <listener-class>com.test.CustomListener</listener-class>
  </listener>

예) 이전적용 예 2. 

@WebListener
public class InitialCustomListener implements ServletContextListener {
...
}

SpringBoot 적용방법

Type I.

@Component annotation을 적용하여 등록한 Bean class 에  ApplicationListener interface구현

 @Component   
 public class CustomListener implements ApplicationListener<ApplicationStartedEvent> {
 
    @Override
	public void onApplicationEvent(ApplicationStartedEvent applicationStartedEvent) {
      //... Biz Logic
    }
 }

Type II.

SpringBootApplication 에 직접 Listener 등록

@SpringBootApplication 
@ComponentScan(basePackages = "com.test")
public class MyApplication { 
  public static void main(String[] args) { 
  
    SpringApplication sap = new SpringApplication(MyApplication.class); 
    //Listener 추가
    sap.addListeners(new CustomListener()); 
    sap.addListeners(...);
    //Initializer 추가
    sap.addInitializers(...);
    sap.run(args); 
  } 
}

II. 외부 properties 를 적용하는 방법

개발된 jar 를 전달하여 적용하고자 할때 해당 DB 나 service port 등을 구동시 반영하고자 할때 application.properties 를 외부로 빼서 이를 start 시 적용하기 위한 방법

java -jar test-0.0.1-SNAPSHOT.jar --spring.config.location=application.properties --debug

III. MyBatis 적용을 위한 방법

 

 1. Mapper Class Scan 방법

@SpringBootApplication 
@MapperScan(basePackages = "com.test.mapper") //MyBatis Mapper Scan추가
public class MyApplication { 
  public static void main(String[] args) { 
  ... 이하 생략
  

 

 2. Mapper xml 에서 Return 시 컬럼값을 CamelCase로 자동변환하여 조회하는 설정

mybatis.configuration.map-underscore-to-camel-case=true

# mybatis 매핑 type을 짧게 쓰기 위한 설정
mybatis.type-aliases-package=com.test.dto

 

To Be Continue...



« PREV : 1 : 2 : 3 : 4 : 5 : 6 : 7 : 8 : ··· : 127 : NEXT »