디시인사이드 갤러리

갤러리 이슈박스, 최근방문 갤러리

갤러리 본문 영역

이거 뭐가 문제임요라...앱에서 작성

ㅇㅇ갤로그로 이동합니다. 2025.04.03 12:27:48
조회 51 추천 0 댓글 2

package ch04_p01.ems;



import org.springframework.context.support.GenericXmlApplicationContext;



import ch04_p01.ems.member.Student;

import ch04_p01.ems.member.dao.StudentDao;

import ch04_p01.ems.member.service.EMSInformationService;

import ch04_p01.ems.member.service.PrintStudentInformationService;

import ch04_p01.ems.member.service.StudentDeleteService;

import ch04_p01.ems.member.service.StudentModifyService;

import ch04_p01.ems.member.service.StudentRe1gisterService;

import ch04_p01.ems.member.service.StudentSelectService;

import ch04_p01.ems.utils.InitSampleData;



public class MainClass {



    public static void main(String[] args) {

        /*

         * IoC 컨테이너 생성

         */

        GenericXmlApplicationContext ctx = new GenericXmlApplicationContext("classpath:applicationContext.xml");



        // 샘플 데이터

        InitSampleData initSampleData = ctx.getBean("initSampleData", InitSampleData.class);

        String[] sNums = initSampleData.getsNums();

        String[] sIds = initSampleData.getsIds();

        String[] sPws = initSampleData.getsPws();

        String[] sNames = initSampleData.getsNames();

        int[] sAges = initSampleData.getsAges();

        String[] sGenders = initSampleData.getsGenders();

        String[] sMajors = initSampleData.getsMajors();



        // 데이터베이스에 샘플 데이터 저장

        StudentRe1gisterService re1gisterService = ctx.getBean("studentRe1gisterService", StudentRe1gisterService.class);

        for (int i = 0; i < sNums.length; i++) {

            re1gisterService.re1gister(new Student(sNums[i], sIds[i], sPws[i], sNames[i], sAges[i], sGenders[i], sMajors[i]));

        }



        // 학생 리스트

        PrintStudentInformationService printStudentInformationService = ctx.getBean("printStudentInformationService", PrintStudentInformationService.class);

        printStudentInformationService.printStudentsInfo();



        re1gisterService = ctx.getBean("studentRe1gisterService", StudentRe1gisterService.class);

        re1gisterService.re1gister(new Student("hbs006", "deer", "p0006", "melissa", 26, "W", "Music"));

        StudentDao studentDao = ctx.getBean("studentDao", StudentDao.class);

        System.out.println("re1gister() 후 studentDB: " + studentDao.getStudentDB().keySet());



        printStudentInformationService.printStudentsInfo();



        StudentSelectService selectService = ctx.getBean("studentSelectService", StudentSelectService.class);

        System.out.println("select() 전 studentDB: " + studentDao.getStudentDB().keySet());

        Student selectedStudent = selectService.select("hbs006");



        System.out.println("STUDENT START ---------------------");

        System.out.print("sNum:" + selectedStudent.getsNum() + "\t");

        System.out.print("sId:" + selectedStudent.getsId() + "\t");

        System.out.print("sPw:" + selectedStudent.getsPw() + "\t");

        System.out.print("sName:" + selectedStudent.getsName() + "\t");

        System.out.print("sAge:" + selectedStudent.getsAge() + "\t");

        System.out.print("sGender:" + selectedStudent.getsGender() + "\t");

        System.out.println("sMajor:" + selectedStudent.getsMajor());

        System.out.println("END ---------------------");



        StudentModifyService modifyService = ctx.getBean("studentModifyService", StudentModifyService.class);

        modifyService.modify(new Student("hbs006", "pig", "p0066", "melissa", 27, "W", "Computer"));



        printStudentInformationService.printStudentsInfo();



        StudentDeleteService deleteService = ctx.getBean("studentDeleteService", StudentDeleteService.class);

        deleteService.delete("hbs005");



        printStudentInformationService.printStudentsInfo();



        EMSInformationService emsInformationService = ctx.getBean("emsInformationService", EMSInformationService.class);

        emsInformationService.printEMSInformation();



        ctx.close();

    }

}



ㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡ



package ch04_p01.ems.member.service;



import ch04_p01.ems.member.Student;

import ch04_p01.ems.member.dao.StudentDao;



public class StudentSelectService {

private StudentDao studentDao;


public StudentSelectService(StudentDao studentDao) {

this.studentDao = studentDao;

}


public Student select (String sNum) {

if (verify(sNum)) {

return studentDao.select(sNum);

} else {

System.out.println("Student information is unavailable");

}

return null;

}


public boolean verify(String sNum) {

Student student = studentDao.select(sNum);

return student == null ? true : false;

}

}



ㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡ



<?xml version="1.0" encoding="UTF-8"?>



       xsi:schemaLocation="http://www.springframework.org/schema/beans

                           http://www.springframework.org/schema/beans/spring-beans.xsd">



    <!-- InitSampleData 빈 -->

    <bean id="initSampleData"

          class="ch04_p01.ems.utils.InitSampleData">

        <property name="sNums">

            <array>

                <value>hbs001</value>

                <value>hbs002</value>

                <value>hbs003</value>

                <value>hbs004</value>

                <value>hbs005</value>

            </array>

        </property>

        <property name="sIds">

            <array>

                <value>rabbit</value>

                <value>hippo</value>

                <value>raccoon</value>

                <value>elephant</value>

                <value>lion</value>

            </array>

        </property>

        <property name="sPws">

            <array>

                <value>p0001</value>

                <value>p0002</value>

                <value>p0003</value>

                <value>p0004</value>

                <value>p0005</value>

            </array>

        </property>

        <property name="sNames">

            <array>

                <value>agatha</value>

                <value>barbara</value>

                <value>chris</value>

                <value>doris</value>

                <value>elva</value>

            </array>

        </property>

        <property name="sAges">

            <array>

                <value>19</value>

                <value>22</value>

                <value>20</value>

                <value>27</value>

                <value>19</value>

            </array>

        </property>

        <property name="sGenders">

            <array>

                <value>M</value>

                <value>W</value>

                <value>W</value>

                <value>M</value>

                <value>M</value>

            </array>

        </property>

        <property name="sMajors">

            <array>

                <value>English</value>

                <value>Korean</value>

                <value>French</value>

                <value>Philosophy</value>

                <value>History</value>

            </array>

        </property>

    </bean>



    <!-- StudentDao 빈 -->

    <bean id="studentDao"

          class="ch04_p01.ems.member.dao.StudentDao" />



    <!-- StudentRe1gisterService 빈 생성 -->

    <bean id="studentRe1gisterService"

          class="ch04_p01.ems.member.service.StudentRe1gisterService">

        <constructor-arg ref="studentDao" />

    </bean>



    <!-- StudentModifyService 빈 생성 -->

    <bean id="studentModifyService"

          class="ch04_p01.ems.member.service.StudentModifyService">

        <constructor-arg ref="studentDao" />

    </bean>



    <!-- StudentDeleteService 빈 생성 -->

    <bean id="studentDeleteService"

          class="ch04_p01.ems.member.service.StudentDeleteService">

        <constructor-arg ref="studentDao" />

    </bean>



    <!-- StudentSelectService 빈 생성 -->

    <bean id="studentSelectService"

          class="ch04_p01.ems.member.service.StudentSelectService">

        <constructor-arg ref="studentDao" />

    </bean>



    <!-- StudentAllSelectService 빈 생성 -->

    <bean id="studentAllSelectService"

          class="ch04_p01.ems.member.service.StudentAllSelectService">

        <constructor-arg ref="studentDao" />

    </bean>



    <!-- PrintStudentInformationService 빈 생성 -->

    <bean id="printStudentInformationService"

          class="ch04_p01.ems.member.service.PrintStudentInformationService">

        <constructor-arg ref="studentAllSelectService" />

    </bean>



    <!-- DBConnectionInfo 빈 -->

    <!-- 개발에 사용하는 데이터베이스 빈 생성 -->

    <bean id="dev_DBConnectionInfoDev"

          class="ch04_p01.ems.member.DBConnectionInfo">

        <property name="url" value="000.000.000.000" />

        <property name="userId" value="admin" />

        <property name="userPw" value="0000" />

    </bean>



    <!-- 실제 서비스에 이용하는 데이터베이스 빈 생성 -->

    <bean id="real_DBConnectionInfo"

          class="ch04_p01.ems.member.DBConnectionInfo">

        <property name="url" value="111.111.111.111" />

        <property name="userId" value="master" />

        <property name="userPw" value="1111" />

    </bean>



    <!-- EMSInformationService 빈 -->

    <bean id="emsInformationService"

          class="ch04_p01.ems.member.service.EMSInformationService">

        <property name="info"

                  value="Education Management System program was developed in 2022." />

        <property name="copyRight"

                  value="COPYRIGHT (C) 2022 EMS CO., LTD. ALL RIGHT RESERVED. CONTACT MASTER FOR MORE INFORMATION." />

        <property name="ver" value="The version is 1.0" />

        <property name="sYear" value="2022" />

        <property name="sMonth" value="3" />

        <property name="sDay" value="1" />

        <property name="eYear" value="2022" />

        <property name="eMonth" value="4" />

        <property name="eDay" value="30" />

        <property name="developers">

            <list>

                <value>Cheney.</value>

                <value>Eloy.</value>

                <value>Jasper.</value>

                <value>Dillon.</value>

                <value>Kian.</value>

            </list>

        </property>

      

            <!-- administrators 필드 초기화 -->

    <property name="administrators">

        <map>

            <entry>

                <key>

                    <value>Cheney</value>

                </key>

                <value>cheney@springPjt.org</value>

            </entry>

            <entry>

                <key>

                    <value>Jasper</value>

                </key>

                <value>jasper@springPjt.org</value>

            </entry>

        </map>

    </property>



    <!-- dbInfos 필드 초기화 -->

    <property name="dbInfos">

        <map>

            <!-- 개발용 데이터베이스 지정 -->

            <entry>

                <key>

                    <value>dev</value>

                </key>

                <ref bean="dev_DBConnectionInfoDev" />

            </entry>

            <!-- 실제 서비스 데이터베이스 지정 -->

            <entry>

                <key>

                    <value>real</value>

                </key>

                <ref bean="real_DBConnectionInfo" />

            </entry>

        </map>

    </property>

      

    </bean>





</beans>


hbs006 등록후 전체출력 자체는 되는데 select에서 오류남
그럴 이유가 있나? gpt랑 놀아봤는데 모르겠음...

추천 비추천

0

고정닉 0

0

댓글 영역

전체 댓글 0
등록순정렬 기준선택
본문 보기

하단 갤러리 리스트 영역

왼쪽 컨텐츠 영역

갤러리 리스트 영역

갤러리 리스트
번호 제목 글쓴이 작성일 조회 추천
설문 소속 연예인 논란에 잘 대응하지 못하는 것 같은 소속사는? 운영자 25/04/21 - -
2841341 이거 니들은 뭔 말인지 이해됨 ㅇㅅㅇ? [16] 강유현갤로그로 이동합니다. 04.09 88 1
2841340 넥도리아 새끼는 [33] RyuDOG갤로그로 이동합니다. 04.09 55 0
2841338 파스칼 붐은 오지않는가 ㅇㅅㅇ 강유현갤로그로 이동합니다. 04.09 27 0
2841337 깃허브로 유니티 협?업할 때 어케하나요 [9] 프갤러(59.5) 04.09 55 0
2841336 앞으로 전망 높은 언어 >>>> 코볼 COBOL [1] 프갤러(59.16) 04.09 44 0
2841335 짱개새끼들이 선만 안넘었으면 [19] RyuDOG갤로그로 이동합니다. 04.09 60 0
2841334 도시살면 배구공(119.202) 04.09 24 0
2841333 늬들은 꼭 효도해라 [1] 배구공(119.202) 04.09 41 0
2841332 씨샵 11 이상 최신버전은 스펙이 좀 적응이 안되는데 [7] ㅇㅇ(122.36) 04.09 61 0
2841331 전 회사에서 병신같은 PM 컴 잘안다고 나댔었는디 ㅇㅅㅇ [2] 강유현갤로그로 이동합니다. 04.09 51 0
2841330 간철수는 근데 솔직히 RyuDOG갤로그로 이동합니다. 04.09 44 0
2841329 회사에선 자바, 혼자서는 프흐프 [2] 슈퍼막코더(126.233) 04.09 40 0
2841328 42경산 좆같은듯 [1] 프갤러(218.144) 04.09 109 0
2841327 우리나라 김문수,이준석,이재명 다 포퓰리스트야 [1] ㅆㅇㅆ찡갤로그로 이동합니다. 04.09 47 0
2841326 어차피 지금 돌아가는 wpf 절반이상이 .net 4.5일듯 ㅇㅅㅇ [6] 강유현갤로그로 이동합니다. 04.09 60 0
2841325 머스크 내분 발명도둑잡기갤로그로 이동합니다. 04.09 38 0
2841324 가난해질수록 포퓰리즘에 빠진다 [10] ㅆㅇㅆ찡갤로그로 이동합니다. 04.09 57 0
2841323 개졸리댱.. ♥냥덩소프트♥갤로그로 이동합니다. 04.09 18 0
2841322 일본 "이재명 민생지원금 정책 보고 배우자" [10] 신종야옹갤로그로 이동합니다. 04.09 400 5
2841321 sDK연동할 때 보니까 대기업일수록 더 레거시 선호하는듯 [6] 강유현갤로그로 이동합니다. 04.09 59 0
2841319 아..형냐들 나 초본데 기절할거 같애 도와줘 [4] ㅇㅇ(115.143) 04.09 35 0
2841317 카카오가 진짜 자바에 미친새끼들 같더라 ㅇㅅㅇ [16] 강유현갤로그로 이동합니다. 04.09 115 0
2841316 윤리강사 이현 선생의 "정의를 말하지 않는 나라" [1] 발명도둑잡기갤로그로 이동합니다. 04.09 35 0
2841315 지금 데톱앱 만들기 젤 편한건 일렉트론인듯 ㅇㅅㅇ [4] 강유현갤로그로 이동합니다. 04.09 60 0
2841314 수학과 물리학 ♥냥덩소프트♥갤로그로 이동합니다. 04.09 26 0
2841313 좀 큰게임 만드는거 현실적으로 시간 넘 걸려서 [4] ㅆㅇㅆ찡갤로그로 이동합니다. 04.09 49 0
2841312 RN expo-router 이거 문제 존나많네 [1] 프갤러(211.234) 04.09 37 0
2841311 C++과 C#중 하나만 써야하면 C++ 맞지? [11] 거북이속이거북갤로그로 이동합니다. 04.09 111 0
2841309 몇대만 더 고치면, 젠폰4 소니 10 ii 액정 61800 내생일에 00 넥도리아(112.170) 04.09 21 0
2841308 마소관련 제품이 ux가 좋음. Wpf도 윈도우도 [6] ㅆㅇㅆ찡갤로그로 이동합니다. 04.09 56 0
2841307 ❤✨☀⭐나님 시작합니당⭐☀✨❤ ♥냥덩소프트♥갤로그로 이동합니다. 04.09 20 0
2841306 ㅂㅅ들 나이트 룸하나 잡고 텐프로 10명 불러서 [3] 배구공(119.202) 04.09 60 0
2841305 조선을 탈출하자 [2] 아스카영원히사랑해갤로그로 이동합니다. 04.09 44 0
2841303 노가다하고 집가서 코딩하고 [2] ㅆㅇㅆ찡갤로그로 이동합니다. 04.09 45 0
2841302 ㅇㅇㅇ 프갤러(219.248) 04.09 27 0
2841301 텟프프프 개인 프로젝트 성공하고 포폴 보강해서 런하는테치! 프갤러(27.170) 04.09 28 0
2841300 아빠 없이 크는 아이에 대한 사유리의 생각 [1] 발명도둑잡기갤로그로 이동합니다. 04.09 39 0
2841299 근데 진지하게 Qt거르고 WPF쓰는 메리트잇삼? [9] 거북이속이거북갤로그로 이동합니다. 04.09 71 0
2841298 씨샵 없으면 나같은 저능아가 무슨 코딩하겠냐 [2] ㅆㅇㅆ찡갤로그로 이동합니다. 04.09 53 0
2841297 테에에에엥 코노 와타치 주니어인 데수웅 프갤러(27.170) 04.09 24 0
2841296 일본 "이재명 민생지원금 정책 보고 배우자" [1] 신종야옹갤로그로 이동합니다. 04.09 43 0
2841295 프로그래밍 갤러리라서 if,for이런거 이야기하는줄 알았는데 [5] 프갤러(118.235) 04.09 55 0
2841292 Managed Lang에서 문자열 보간 지원 안 하는거 머있냐 ㅇㅅㅇ [11] 강유현갤로그로 이동합니다. 04.09 55 0
2841291 씨샵 참 매력적인 언어임 [5] ㅇㅇ(211.234) 04.09 70 0
2841290 Clr이 값,참조 분리도 편하게해놨고 task도 편한데 [4] ㅆㅇㅆ찡갤로그로 이동합니다. 04.09 47 0
2841289 씨샵 모르면 가만히 있어라 [1] 배구공(119.202) 04.09 46 0
2841288 솔직히 씨샵이 약간 LG전자 같은 포지션임 ㅇㅅㅇ [2] 강유현갤로그로 이동합니다. 04.09 52 0
2841287 형들 국비지원 받을려는 32살 백수인데 [3] 프갤러(121.139) 04.09 192 0
2841286 Clr은 왜 다른 언어에서 채용 안할까 [2] ㅆㅇㅆ찡갤로그로 이동합니다. 04.09 38 0
2841284 미국 관세전쟁으로 미국 패권주의 끝나고 윈도우 점유율 낮아질수록 [6] ㅆㅇㅆ찡갤로그로 이동합니다. 04.09 57 0
뉴스 ‘올라운더’ 도경수, ‘언슬전’ 멜로 감성 높인다…OST ‘영원해’ 참여 디시트렌드 04.26
갤러리 내부 검색
제목+내용게시물 정렬 옵션

오른쪽 컨텐츠 영역

실시간 베스트

1/8

뉴스

디시미디어

디시이슈

1/2