9일차 1 - Java Project Import하기, 서버환경에서 띄우기
자바프로젝트 import하기
day5 프로젝트
압축해가져가 (밤톨이 같은 일부 ‘.’ 으로 시작하는 파일 압축못하는 압축프로그램 피해)
압축해 가져갔다치고 프로젝트 삭제해봐
체크해야 하드디스크에서도 삭제돼.
이제 압축풀고 Import
Browse..하면 workspace자동으로 잡히고 새로운게 프로젝트 밑에 나타나
finish하면 끝.
다른 방법으로 war이용
export->WAR File
- Export source files체크안하면 class파일만 export돼. 소스코드 챙기려면 반드시 체크.
- overwrite 는 체크해도 잘 안되니까 반드시 지우고 다시 만들어..
import->WAR File
war파일 언제쓰지?
우리가 tomcat을 이클립스에서 돌리고 있지만 실제에선 이클립스를 띄워놓고 웹서비스를 하진 안잖아. 실제 웹서버는 어디냐 하면
C:\Java\apache-tomcat-7.0.27\bin에서 startup.bat으로 실행해.. 안되네.. 음.
먼저 JAVA_HOME 환경변수 잡아야지
- Path C:\Java\jdk1.7.0_03\bin –> %JAVA_HOME%\bin
- JAVA_HOME C:\Java\jdk1.7.0_03
cf. 환경변수 우선순위 : System –> 왼쪽
이제 cmd나 더블클릭으로 startup.bat 실행해. 이제 실행되지. 그래도 안되는건 이클립스에 tomcat이 떠있기 때문일거야. 이클립스에서 서버stop.
그리고 http://127.0.0.1 http://자기 아이피 혹은 http://localhost 하면.. 안되네..
포트번호가 틀려서 그런가.. 80포트가 안뜨고 8080으로 뜨려고 해서 그런가.. 오라클 깔고나면 자동으로 띄우는 아파치톰캣이 있는데 그거랑 충돌일 수도..
C:\Java\apache-tomcat-7.0.27\conf\server.xml을 에디터로 열어봐
<Connector port="8080" protocol="HTTP/1.1" connectionTimeout="20000" redirectPort="8443" />
포트번호 8080을 80으로 바꾸고 저장.
이제 다시 시작하고 다시 하면
짜잔
이렇게 웹서버를 띄우고 실행하는거지..
C:\Windows\System32\drivers\etc\hosts 파일열면
# Copyright (c) 1993-2009 Microsoft Corp. # # This is a sample HOSTS file used by Microsoft TCP/IP for Windows. # # This file contains the mappings of IP addresses to host names. Each # entry should be kept on an individual line. The IP address should # be placed in the first column followed by the corresponding host name. # The IP address and the host name should be separated by at least one # space. # # Additionally, comments (such as these) may be inserted on individual # lines or following the machine name denoted by a '#' symbol. # # For example: # # 102.54.94.97 rhino.acme.com # source server # 38.25.63.10 x.acme.com # x client host # localhost name resolution is handled within DNS itself. # 127.0.0.1 localhost # ::1 localhost
이 파일을 읽어서 http://localhost 이 실행되는거야..
보통 개발중일때 만일 도메인이 oracle.java.com이라면 다른 사람들이 개발중에 들어올 수가 있잖아.. 그러니까 그쪽에는 개발중이라고 띄워놓고 이 파일을 변경해서 oracle.java.com 해놓고 개발하는거지. 그럼 밖에 DNS안나가고 컴퓨터내에서 작업이 되지..
war파일 사용
C:\Java\apache-tomcat-7.0.27\webapps\ROOT 이게 원래 web root야
여기에 업로드 하면 돼. root디렉토리에 폴더채로 갖다붙이면 힘들잖아. war파일을 C:\Java\apache-tomcat-7.0.27\webapps 집어넣으면 자동으로 deploy되..
자동빌드하는 스크립트 나중에…..
http://localhost/webdev/index.jsp 실행하면
tomcat서버를 띄우는 여러가지 파일이 있는데 startup.bat으로 실행하면 메세지가 다 보여.(System.out.print랑 에러메세지들 다 찍혀), 간단히 실행시키려면 tomcat7w.exe로 실행(윈도우 인스톨버전으로 깔았을 경우)