스프링 프로젝트

BroJang·2022년 10월 31일

스프링

목록 보기
5/10

프로젝트 기획

  • 회원 관리 (로그인, 회원가입, 마이페이지, 찾기 기능, 탈퇴)

  • 게시판 (목록, 조회, 작성, 수정, 삭제, 댓글)

추가적인 기능들은 우선 목표로 하는 해당 기능들이 모두 구현이 되고 나면 차기 프로젝트에서 해볼 예정입니다.

개발 환경
OS : windows 11
DB : Oracle(SQL Developer 사용)
JDK : JDK 11
Server : Apache Tomcat 9.0
maven : 3.8.6 사용
IDE : IntelliJ 사용
Spring (version 5.3.23)+ MYBATIS 활용(MVC Model 2 활용)

DB 설계

create table member_tb(
mno number primary key,
mname varchar2(10) not null,
mid varchar2(50) not null,
mnickname varchar2(20) not null,
mpassword varchar2(50) not null,
mfindpassword varchar2(10) not null,
memail varchar2(50) not null,
mjoindate date default sysdate,
mresigndate date,
mresign varchar2(1) default 'N'
);

create table board_tb(
bno number primary key,
bwriter varchar2(20) not null,
btitle varchar2(100) not null,
bcontent varchar2(2000) not null,
bhitcount number not null,
bregdate date default sysdate,
bupdate date,
bdeldate date,
bdelboard varchar2(1) default 'N'
);

create table board_comment_tb(
bno number not null,
comno number not null,
comwriter varchar2(20) not null,
comcontent varchar2(2000) not null,
comregdate date default sysdate,
comdeldate date,
comdelete varchar2(1) default 'N'
);

-- no증가용 시퀀스
create sequence member_seq
start with 1
INCREMENT by 1
MINVALUE 1
nocycle
nocache;

create sequence board_seq
start with 1
INCREMENT by 1
MINVALUE 1
nocycle
nocache;

create sequence comment_seq
start with 1
INCREMENT by 1
MINVALUE 1
nocycle
nocache;

탈퇴 여부나 글 삭제 등 여부를 확인하기 위해 'N','Y'로 구분지을 예정입니다.

탈퇴 시 deldate로도 null이 아닌걸로 조회가 가능한데
추후 DB를 변경하기엔 어려운 부분도 있을 것 같고, 기능구현 + 유지보수를 생각해서 넣었습니다.

id값은 primary로 하기보다 스크립트 코드로 중복적용 확인을 해보려고 primary, unique를 넣지 않았습니다.

DBCP로는 Hikari를 사용 (성능이 우수)

applicationContext.xml

    <bean id="hikariConfig" class="com.zaxxer.hikari.HikariConfig">
        <property name="driverClassName" value="net.sf.log4jdbc.sql.jdbcapi.DriverSpy"></property>
        <property name="jdbcUrl" value="jdbc:log4jdbc:oracle:thin:@localhost:1521:xe"></property>
        <property name="username" value="hr"></property>
        <property name="password" value="hr"></property>
    </bean>
    <bean id="datasource" class="com.zaxxer.hikari.HikariDataSource" destroy-method="close">
        <constructor-arg ref="hikariConfig"></constructor-arg>
    </bean>

    <bean id="sqlSessionFactory" class="org.mybatis.spring.SqlSessionFactoryBean">
        <property name="dataSource" ref="datasource"></property>
    </bean>

    <mybatis-spring:scan base-package="com.brojang.mapper"/>
    <context:component-scan base-package="com.brojang.model.vo"></context:component-scan>
    <context:component-scan base-package="com.brojang.model.service"></context:component-scan>

mybatis는 com.brojang.mapper 패키지에서 스캔을 시작하도록 지정


dispatcher-servlet.xml

<?xml version="1.0" encoding="UTF-8"?>
<!-- servlet-context.xml과 동일파일 -->
<beans xmlns="http://www.springframework.org/schema/beans"
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
       xmlns:context="http://www.springframework.org/schema/context"
       xmlns:mvc="http://www.springframework.org/schema/mvc"
       xsi:schemaLocation="http://www.springframework.org/schema/beans
       http://www.springframework.org/schema/beans/spring-beans.xsd
       http://www.springframework.org/schema/context
       http://www.springframework.org/schema/context/spring-context.xsd
       http://www.springframework.org/schema/mvc
       https://www.springframework.org/schema/mvc/spring-mvc.xsd">

    <mvc:annotation-driven/>

    <mvc:resources mapping="/resources/**" location="/resources/"/>

    <bean class="org.springframework.web.servlet.view.InternalResourceViewResolver">
        <property name="prefix" value="/WEB-INF/views/" />
        <property name="suffix" value=".jsp"/>
    </bean>

    <context:component-scan base-package="com.brojang.model.controller"/>

</beans>

com.brojang.model.controller 패키지를 기준으로 클래스를 스캔한다. (Controller 스캔 목적)

나머지는 기능 구현하면서 순차적으로 적어보겠습니다.

profile
끊임없이 배우고 진보하는 백엔드 개발자입니다. 배움에 있어서 최선을 다하자!

0개의 댓글