woong's

서버 war 배포 본문

Develop/Server

서버 war 배포

dlsdnd345 2016. 2. 13. 19:12
336x280(권장), 300x250(권장), 250x250, 200x200 크기의 광고 코드만 넣을 수 있습니다.

서버 war 배포

1. 처음에 war를 배포를 Export로 해서 war 파일을 만들었음.
하지만 그렇게 war 파일을 만드니 lib 등 여러 파일들이 만들어지지 않음.
maven 을 통해서 war 파일을 만들어야 war 파일이 정상적으로 만들어짐.

준비과정

1.tomcat zip 버젼을 받는다. (Tomcat Install 버젼을 다운로드하면 에러 코드를 볼수 없다.)



2. 받을시에 program Files 에 압축을 풀지 않는다. (이곳에 압축을 풀게 되면 권한여부로 인해 접근이 않될수있다.)

3. 환경변수 설정

기본적으로 자바 환경변수 설정이 완료되있어여 하고 완료된후,
CATALINA_HOME : C:\apache-tomcat-6.0.37(톰캣 설치경로)
path : C:\apache-tomcat-6.0.37/bin (톰캣 빈 경로)
를 설정해준다 .

4. 톰캣 실행

cmd 창 실행 - 톰캣 bin 폴더로 이동 - startup 명령어 실행

 

 

 

5. 톰캣 매니져

톰캣 매니져를 접근하기 위해서는 아이디/비밀번호가 필요.
하지만 Tomcat Zip 으로 다운받았을 경우 초기 아이디와 비밀번호가 설정이 되어있지 않음.
초기설정을 하기 위해서 톰캣 conf 폴더로 이동 - tomcat-users.xml 에 아이디와 비밀번호를 설정.

 


<tomcat-users> <!-- NOTE: By default, no user is included in the "manager-gui" role required to operate the "/manager/html" web application. If you wish to use this app, you must define such a user - the username and password are arbitrary. --> <!-- NOTE: The sample user and role entries below are wrapped in a comment and thus are ignored when reading this file. Do not forget to remove <!.. ..> that surrounds them. --> <role rolename="manager-script"/> <role rolename="manager-gui"/> <role rolename="manager-jmx"/> <role rolename="manager-status"/> <user username="root" password="qkr50715071" roles="manager-gui,manager-status"/> </tomcat-users>

war 배포 설정

pom.xml 에 plugin 을 추가.

 

1. plugin 준비


<plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-war-plugin</artifactId> <configuration> <failOnMissingWebXml>false</failOnMissingWebXml> </configuration> </plugin>

배포

1. war 파일 생성




cmd 창을 통해서 명령어를 실행하면

 

 

 

아래 경로에 war 파일이 생성된것을 볼수 있음.

war 파일 이동

C:\app\apache-tomcat-8.0.0-RC1\webapps(Tomcat webapps 폴더로 이동)

 

 

4. 톰캣 실행

cmd 창 실행 - 톰캣 bin 폴더로 이동 - startup 명령어 실행
위 경로에 war 파일이 압축이 풀려서 폴더가 생성되는것을 볼수 있음.

주의

톰캣 서버가 실행이 잘되지만 page 404 에러가 나는경우에는 cmd 창에 에러가 없는지 확인한다.
(1.logback dependency 가없어 에러가 나타났으나 한줄로 표시되고 서버가 실행되서 발견하는데 시간이걸림.
2. properties 파일이 src/test/resources 에있어 properties 파일을 찾지못함 . => src/main/resources 로 이동
3. DomainConfiguration 에 @PropertySource 에 file:src / ~~ 절대경로로 잡혀 있어 오류 발생 => @PropertySource("classpath:properties") 상대경로 지정)

 

tomcat manager 실행

http://localhost:8080/manager/html

 

 

 

해당 프로젝트 선택

주의

마지막으로 홈페이지의 절대경로로 접근하는 경우 이벤트 발생시 페이지 경로를 못찾는 경우가 생긴다 .
그러므로 절대경로를 => 상대경로로 바꾸어 주어야한다.


Comments