english
Last Modified 2025.2.24

윈도 11에서 '자바 웹 프로그래밍' 최종 소스 테스트

Java 설치

https://www.oracle.com/java/technologies/downloads
최신 LTS 버전을 선택해 설치한다. 자바 설치 참조

Maven 설치

https://maven.apache.org/download.cgi
최신 버전의 바이너리 파일(Binary zip archive)을 내려받아 압축을 풀고 생성된 디렉터리를 원하는 곳에 복사한 후, bin 폴더 경로를 시스템 변수의 Path에 추가한다. 메이븐 설치 참조

Git 설치

https://git-scm.com/download/win
64-bit Git for Windows Setup 파일을 내려받아 설치한다. (설치 옵션은 모두 디폴트로)

설치 후, 이름과 이메일을 설정한다.

 
git config --global user.name "Gildong Hong"
git config --global user.email hong@gmail.org

확인

 
git config --global --list 

Oracle Database 11gR2 Express Edition 설치

https://www.oracle.com/database/technologies/xe-prior-release-downloads.html
64비트 윈도 시스템이면, --대부분 시스템이 64비트 시스템이다-- Oracle Database 11gR2 Express Edition for Windows x64를 내려받는다. 이 버전을 내려받으려면 오라클 사이트의 계정이 필요하다. 회원가입을 하고 로그인하면 내려받기가 시작된다.

윈도는 오라클이 공식 지원하는 OS이기에 간단히 설치할 수 있다.
내려받은 압축 파일을 풀고, Disk1 폴더에서 setup.exe를 실행한 후, 다음 버튼을 계속 눌러 설치한다.
설치 과정에서 자신이 지정한 관리자 비밀번호는 잊지 않도록 한다.

11g XE 구성 요소 중 Oracle Application Express는 8080 포트를 사용한다.
8080 포트는 톰캣이 사용해야 하므로 Apex 포트를 바꾸어 준다.
다음은 Apex 포트를 9090으로 바꾸는 방법이다.

 
C:\Users> sqlplus
Enter user-name: system
Enter password:
Connected.

SQL> Exec DBMS_XDB.SETHTTPPORT(9090);

PL/SQL procedure successfully completed.

SQL>

톰캣 설치

https://tomcat.apache.org/download-11.cgi
Windows Service Installer 내려받아 설치한다. 톰캣 설치 참조

테스트

책 예제 복사

git을 사용해 예제를 내려받는다.

git clone https://github.com/kimjonghoon/JavaWebProgramming

글의 통일성을 위해, 생성된 JavaWebProgramming 폴더를 C:\ 위치로 옮긴다.

업로드 디렉터리 수정

net.java_school.commons 패키지의 WebContants.java 파일에서 업로드 디렉터리를 자신의 시스템에 맞게 수정한다.

로그 파일 경로 수정

src/main/resources 폴더의 log4j2.xml 파일에서 로그 파일 경로를 자신의 시스템에 맞게 수정한다.

오라클 데이터베이스 스키마

sqlplus sys as sysdba

Copyright (c) 1982, 2011, Oracle.  All rights reserved.
Enter password: 

Connected to:
Oracle Database 11g Express Edition Release 11.2.0.2.0 - 64bit Production

GRANT CONNECT,RESOURCE,UNLIMITED TABLESPACE TO java IDENTIFIED BY school;

conn java/school
Connected.


create table member (
    email varchar2(60) PRIMARY KEY,
    passwd varchar2(200) NOT NULL,
    name varchar2(20) NOT NULL,
    mobile varchar2(20)
);

create table board (
    boardcd varchar2(20),
    boardnm varchar2(40) NOT NULL,
    boardnm_ko varchar2(40),
    constraint PK_BOARD PRIMARY KEY(boardcd)
);

create table article (
    articleno number,
    boardcd varchar2(20),
    title varchar2(200) NOT NULL,
    content clob NOT NULL,
    email varchar2(60),
    hit number,
    regdate date,
    constraint PK_ARTICLE PRIMARY KEY(articleno),
    constraint FK_ARTICLE FOREIGN KEY(boardcd) REFERENCES board(boardcd)
);

create sequence SEQ_ARTICLE
    increment by 1
    start with 1;

create table comments (
    commentno number,
    articleno number,    
    email varchar2(60),    
    memo varchar2(4000) NOT NULL,
    regdate date, 
    constraint PK_COMMENTS PRIMARY KEY(commentno)
);

create sequence SEQ_COMMENTS
    increment by 1
    start with 1;

create table attachfile (
    attachfileno number,
    filename varchar2(50) NOT NULL,
    filetype varchar2(30),
    filesize number,
    articleno number,
    email varchar2(60),
    constraint PK_ATTACHFILE PRIMARY KEY(attachfileno)
);

create sequence SEQ_ATTACHFILE
    increment by 1
    start with 1;

create table authorities (
    email varchar2(60) NOT NULL,
    authority varchar2(20) NOT NULL,
    constraint fk_authorities FOREIGN KEY(email) REFERENCES member(email)
);

CREATE UNIQUE INDEX ix_authorities ON authorities(email, authority); 

create table views (
    no number,
    articleNo number,
    ip varchar(60),
    yearMonthDayHour char(10),
    constraint PK_VIEWS PRIMARY KEY(no),
    constraint UNIQUE_VIEWS UNIQUE(articleNo, ip, yearMonthDayHour)
);

create sequence SEQ_VIEWS
    increment by 1
    start with 1;

-- for test records  
insert into board values ('chat', 'Chat', '자유게시판');
commit;

ROOT.xml

C:\JavaWebProgramming가 루트 디렉터리이므로, 다음과 같이 ROOT.xml 파일을 작성하고, 톰캣의 conf/Catalina/localhost 폴더에 복사한다. --폴더가 없으면 생성한다--

<?xml version="1.0" encoding="UTF-8"?>
<Context
  docBase="C:/JavaWebProgramming/src/main/webapp"
  reloadable="true">
</Context>

컴파일

 
mvn clean compile war:inplace

톰캣을 재시작하고, http://localhost:8080를 방문, 회원가입을 하고 게시판을 테스트한다.

관리자 모드 테스트

회원을 지정해, 관리자 권한을 부여한다.

 
sqlplus java/school

insert into authorities values ('회원 이메일','ROLE_ADMIN');

commit;

exit;

로그아웃 후 다시 로그인하여 관리자 메뉴가 보이는지 확인한다.

Jetty 플러그인을 사용한 테스트

톰캣을 종료한 후, 다음을 실행

 
mvn clean jetty:run
관련 글