[서버 에러]server tomcat v8.5 server at localhost failed to start.


 

<에러>  
[서버 에러]server tomcat v8.5 server at localhost failed to start.

 

<해결>

Preferences > Java > Installed JREs > 기존 jdk Remove 해주고 Add로 환경변수 설정된 jdk 재설정
Preferences > Servers > Runtile Environments > 서버 Edit > 설정된 JRE 선택

이렇게 해도 해결되지 않으면

추가된 서버 더블클릭 후 Server Options 에서 Publish module contexts to separate XML files 체크

 

*publish module contexts to separate xml files 

이클립스에서 환경설정이나 xml 파일 설정시 실제 tomcat 서버와 동기화 시켜주는 옵션

보통 서버 기본 세팅시 설정

'Backend > 기타' 카테고리의 다른 글

JUnit 단위 테스트  (0) 2024.06.03
알고리즘(Algorithm)이란?  (0) 2024.06.02
<url-pattern>  (0) 2024.05.31
[Spring] 한글깨짐 에러  (0) 2024.05.31
[Spring] invalid thread access, download of template~ 에러  (1) 2024.05.31

 

클릭 이벤트 


 

도서관련 웹페이지를 만드는 중에 a 이미지를 기본으로 설정해두고 커서를 올리면 b 이미지로 바뀌는 기능을 구현했다.

클릭하게 되면 상품의 페이지로 이동한다.

 

 

1. HTML 기능추가(.jsp 파일)

home.jsp 파일의 body 안에 입력해준다.

이미지 경로는 상대경로로 입력하면 되고 내 경우에는 설정이 끝났는데도 기능이 구현되지 않아서 코드를 뜯어보니 js 파일 경로가 잘못되어 있었다. 

내 경우는 resources/js/script.js 경로로 수정했더니 잘 작동되었다.

<body>
<div class="product-image">
  <a href="product-page.html"> <!-- 상품 페이지 링크 -->
    <img src="image1.jpg" alt="이미지" id="productImg">
  </a>
</div>
<script src="script.js"></script>
</body>

 

 

2. JavaScript 기능추가(.js 파일)

// JavaScript 파일 내에서 마우스 이벤트와 클릭 이벤트를 처리하여 이미지를 변경하고 페이지로 이동합니다.
const productImg = document.getElementById('productImg');

// 마우스를 올렸을 때의 처리
productImg.addEventListener('mouseenter', function() {
  // 마우스를 올렸을 때의 이미지 경로
  this.src = 'image1.jpg';
});

// 마우스를 내렸을 때의 처리
productImg.addEventListener('mouseleave', function() {
  // 마우스를 내렸을 때의 이미지 경로
  this.src = 'image2.jpg';
});

// 이미지를 클릭했을 때의 처리 (상품 페이지로 이동)
productImg.addEventListener('click', function() {
  window.location.href = 'product-page.html'; // 이동할 페이지의 URL
});

 

1. margin

margin의 속성값을 조절하여 버튼사이 간격조절

 

<button> 첫 번째 버튼</button>

<span style="margin: 0 10px;"></span>

<button> 두 번째 버튼</button>

 

 

 

2. 패딩(padding)을 이용한 간격 조절

 

<button style="margin-right: 10px;">첫 번째 버튼</button>

<button>두 번째 버튼</button>

 

 

 나의 경우 이렇게 적용했다.

 <button class="btn1" style="margin-right: 10px;" type="submit">

 

<url-pattern> 


 

<url-pattern> 요소는 필터가 적용될 URL 패턴을 지정하는 데 사용된다. 

 

  • '/*' : 모든 URL에 대해 필터가 적용된다.

모든 요청에 대해 필터가 적용되어야 할 때 사용되므로 일괄적으로 인코딩 설정이나 보안 등을 적용할 수 있다.

하지만 부하를 초래할 수 있으므로 필요한 경우에만 사용하는 것이 좋다. 

 

  • '/some/*' : "/some/"으로 시작하는 모든 URL에 대해 필터가 적용된다.

 

  • '*.do' : 확장자가 ".do"로 끝나는 모든 URL에 대해 필터가 적용된다.

 

 

1. 이클립스 설정

 초기설정에서 이미 완료된 부분

 

2. web.xml 에 Character Encoding Filter 추가

web.xml 파일 servlet-mapping 하단에 추가한다.

Character Encoding Filter를 추가하여 요청과 응답의 문자 인코딩을 설정한다. 이 필터는 요청의 문자 인코딩을 설정하고응답의 문자 인코딩을 변경하는 데 사용된다. 대부분 UTF-8로 설정하며 이를 통해 한글깨짐 문제를 방지할 수 있다.

 

	<filter>
		<filter-name>encofingFilter</filter-name>
		<filter-class>org.springframework.web.filter.CharacterEncodingFilter</filter-class>
		<init-param>
			<param-name>encoding</param-name>
			<param-value>UTF-8</param-value>
		</init-param>
	</filter>
	<filter-mapping>
		<filter-name>encodingFilter</filter-name>
		<url-pattern>/*</url-pattern>
	</filter-mapping>

 

<url-pattern>

https://saintclair.tistory.com/277

 

3. home.jsp 파일 상단에 태그 추가

jsp 페이지의 인코딩을 UTF-8로 설정하는 페이지 태그를 추가한다.

<%@ page language="java" contentType="text/html; character=utf-8" pageEncoding="UTF-8" %>

 

 

BootStrap 오픈소스 다운 받아 적용하기


 

 

1. 부트스트랩 다운로드

 

2. 압축을 풀고 index 파일을 더블클릭해서 열어준다.

 

3. 해당 페이지에서 마우스 우클릭 > 페이지 소스보기

 

4. 소스를 복사해서 기존 Spring 프로젝트 home.jsp 파일에 붙여넣기 해준다.

(html~ 라인부터)

 

5. 다운받은 폴더 내부에 있는 css, js 등의 폴더를 복사해서 resources 폴더에 넣는다.

 

6. home.jsp 파일에서 link 부분 코드를 알맞은 경로로 수정해준다.

(resources 폴더 안에 위치했으니 기존 경로 앞에 resources/를 추가했음)

 

 

[MySQL] SCHEMA 및 테이블 생성


 

1. Schema 및 테이블 생성

 

MySQL Command Line Client를 이용해 직접 입력해주는 방법도 있지만 Workbench를 사용하면 훨씬 간편하게 스키마 및 테이블을 생성할 수 있다. 데이터 베이스의 구조는 Schema가 Table을 포함하고 Table은 Date를 포함한다고 생각하면 된다.

 

  • Schema 생성

1) MySQL Workbench 실행

2) SCHEMAS 창에서 우클릭 Create Schema 선택

3) 데이터 베이스의 이름을 정하고 저장하면 Schema 생성완료

 

  • Table 생성

1) 생성된 Schema에서 Tables 우클릭 Create Table 선택

2) Table Name를 설정하고 설계한대로 COLUMN을 추가한다. 

 

 

  • 생성된 테이블 컬럼 확인과 더미 데이터 입력 후 데이터 조회 테스트

1) 생성된 테이블 컬럼 확인

MySQL Command Line Client를 실행해 SHOW FULL COLUMNS FROM 스키마명.테이블명; 을 입력한다.

2) 더미 데이터 입력 후 데이터 조회 테스트

INSERT INTO 테이블명 (컬럼1, 컬럼2, 컬럼3, 컬럼4, 컬럼5 ,,,) VALUES (데이터1, 데이터2, 데이터3, 데이터4, 데이터5,,,);

3) 데이터 조회 테스트

SELECT*FROM 스키마명.테이블명;

 

 

 

 

 

 

에러 : Template이 URL을 통해 다운로드가 되어야 하는데 에러가 나면서 다운로드가 안되는 상황이다.

 

 

해결 : 참고 페이지의 zip 파일을 다운받아 
sts3 > workspace > .metadate > .sts > content > org.springframework.templates.mvc-3.2.2에 넣으면 해결된다.

 

MVC 없음 / 템플릿 다운로드 불가 의 경우 수동으로 파일을 넣어주면 된다.

 

MVC 없음의 경우 필요한 파일이 해당 위치에 없기 때문에 발생하는 에러라서 내가 필요한 파일을 해당 위치에 넣어주면 해결되는 것이고, invalid thread access, download of template~ 의 경우는 템플릿 다운로드가 진행되지 않는 상황이기 때문에 해당 템플릿을 기존 프로젝트에서 복사해 다운로드 폴더에 넣어주면 해결되는 것이다. 

 

*참고페이지에서 템플릿 파일을 다운로드 받아 압축을 풀고 해당 폴더에 넣어준 후 프로그램을 재실행하면 된다. 

https://nirsa.tistory.com/405

 

 

'Backend > 기타' 카테고리의 다른 글

<url-pattern>  (0) 2024.05.31
[Spring] 한글깨짐 에러  (0) 2024.05.31
[에러] Spring MVC Template 없음  (0) 2024.05.31
전자정부프레임 압축풀기 에러  (0) 2024.05.30
[Eclipse 실행 에러] an error has occurred. see the log file  (0) 2024.05.29

 

다시 맞닥뜨린 Template 문제.

그동안은 잘 사용했는데 노트북 바꾸고 다시 설치하려니 또 안되는 현상.

다운받은 프로그램 버전이랑 다 확인하고 재설치해도 안된다.

 

  • STS3를 홈페이지에서 다시 다운로드 받아 재설치 
  • sts 폴더 하위 폴더 workspace > .metadata > plugins > org.springsource.ide.eclipse.commons.content.core 를 찾아 https-content.xml 일을 넣어주니 해결
  • 자동으로 다운로드 되지 않으니 수동으로 주입하는 방식으로 해결되었다.

 

전자정부프레임워크를 사용할 때는 저 폴더 자체가 없어서 그래 하는 김에 MVC 구조도 익힐 겸 수동생성 해보자 해서 진행했는데 아무래도 앞으로 프로젝트 만드는데 불편함이 있을 것 같아 해결책을 찾게 되었다. 해당 파일은 구글링 해보면 나온다.

 

 

https-content.xml

더보기

<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<descriptors>
    <descriptor id="org.springframework.templates.mvc" kind="template" local="true" name="Spring MVC Project" requiresbundle="org.eclipse.m2e.core" size="0" version="3.2.2">
        <description>A new Spring MVC web application development project</description>
    </descriptor>
    <descriptor category="GemFire" id="org.springframework.data.gemfire.template.standalone" kind="template" local="false" name="Spring Data GemFire Project (Standalone)" requires="[3.0.0,4.0)" size="7467" url="https://raw.github.com/SpringSource/spring-data-gemfire-sts-templates/master/builds/gemfire-standalone-sts-template-1.0.1.RELEASE.zip" version="1.0.1.RELEASE">
        <description>Creates a Spring Data GemFire project with an embedded cache and one region that runs as a standalone Java application.</description>
    </descriptor>
    <descriptor category="GemFire" id="org.springframework.data.gemfire.template.server.standalone" kind="template" local="false" name="Spring Data GemFire Cache Server Project (Standalone)" requires="[3.0.0,4.0)" size="7582" url="https://raw.github.com/SpringSource/spring-data-gemfire-sts-templates/master/builds/gemfire-server-sts-template-1.0.1.RELEASE.zip" version="1.0.1.RELEASE">
        <description>Creates a GemFire Cache Server project with a cache server, embedded cache and one region that runs as a standalone Java application.</description>
    </descriptor>
    <descriptor category="GemFire" id="org.springframework.data.gemfire.template.server.war" kind="template" local="false" name="Spring Data GemFire Cache Server Project (WAR)" requires="[3.0.0,4.0)" size="7543" url="https://raw.github.com/SpringSource/spring-data-gemfire-sts-templates/master/builds/gemfire-server-war-sts-template-1.0.1.RELEASE.zip" version="1.0.1.RELEASE">
        <description>Creates a GemFire Cache Server project with a cache server, embedded cache and one region that runs as a web application.</description>
    </descriptor>
    <descriptor category="GemFire" id="org.springframework.data.gemfire.template.client" kind="template" local="false" name="Spring Data GemFire Client Project" requires="[3.0.0,4.0)" size="7881" url="https://raw.github.com/SpringSource/spring-data-gemfire-sts-templates/master/builds/gemfire-client-sts-template-1.0.1.RELEASE.zip" version="1.0.1.RELEASE">
        <description>Creates a Spring Data GemFire project with a client cache and client region that runs as a standalone Java application.</description>
    </descriptor>
    <descriptor id="cohttp://m.springsource.sts.org.apache.tomcat" kind="server" local="false" name="Apache Tomcat 6.0.20" size="6282517" url="https://dist.springsource.com/release/STS/help/com.springsource.sts.org.apache.tomcat-6.0.20.20090615-0000.zip" version="6.0.20.20090615-0000">
        <description/>
    </descriptor>
    <descriptor category="Batch" id="org.springframework.samples.batch.admin.web" kind="template" local="false" name="Spring Batch Admin Webapp" requiresbundle="org.eclipse.m2e.core" size="21532" url="https://dist.springsource.com/release/STS/help/org.springframework.samples.batch.admin.web-2.3.3.zip" version="2.3.3">
        <description>A WAR project for a Spring Batch Admin web application with simple custom job</description>
    </descriptor>
    <descriptor id="org.springframework.samples.batch.simple" kind="template" local="false" name="Simple Spring Batch Project" requires="[0.0.0,2.8.0)" size="14198" url="https://dist.springsource.com/release/STS/help/org.springframework.samples.batch.simple-2.3.5.zip" version="2.3.5">
        <description>A simple project that shows how to use Spring Batch with a reader and a writer in a single step job</description>
    </descriptor>
    <descriptor category="Batch" id="org.springframework.samples.batch.simple" kind="template" local="false" name="Simple Spring Batch Project" requires="2.8.0" requiresbundle="org.eclipse.m2e.core" size="13698" url="https://dist.springsource.com/release/STS/help/org.springframework.samples.batch.simple-2.4.2.zip" version="2.4.2">
        <description>A simple project that shows how to use Spring Batch with a reader and a writer in a single step job</description>
    </descriptor>
    <descriptor id="org.springframework.templates.mvc" kind="template" local="false" name="Spring MVC Project" requires="[0.0.0,2.8.0)" size="17198" url="https://dist.springsource.com/release/STS/help/org.springframework.templates.mvc-3.0.18.zip" version="3.0.18">
        <description>A new Spring MVC web application development project</description>
    </descriptor>
    <descriptor id="org.springframework.templates.mvc" kind="template" local="false" name="Spring MVC Project" requires="2.8.0" requiresbundle="org.eclipse.m2e.core" size="16608" url="http://wisejia.iptime.org:8000/org.springframework.templates.mvc-3.2.2.zip" version="3.2.2">
        <description>A new Spring MVC web application development project</description>
    </descriptor>
    <descriptor id="org.springframework.samples.spring.hibernate" kind="template" local="false" name="Simple Spring Hibernate Utility Project" requires="[0.0.0,2.8.0)" size="14052" url="https://dist.springsource.com/release/STS/help/org.springframework.samples.spring.hibernate-2.5.1.zip" version="2.5.1">
        <description>A simple jar project that has some Spring and Hibernate configuration and an integration test</description>
    </descriptor>
    <descriptor category="Persistence" id="org.springframework.samples.spring.hibernate" kind="template" local="false" name="Simple Spring Hibernate Utility Project" requires="2.8.0" requiresbundle="org.eclipse.m2e.core" size="14081" url="https://dist.springsource.com/release/STS/help/org.springframework.samples.spring.hibernate-2.6.2.zip" version="2.6.2">
        <description>A simple jar project that has some Spring and Hibernate configuration and an integration test</description>
    </descriptor>
    <descriptor id="org.springframework.samples.spring.jpa" kind="template" local="false" name="Simple Spring JPA Utility Project" requires="[0.0.0,2.8.0)" size="15587" url="https://dist.springsource.com/release/STS/help/org.springframework.samples.spring.jpa-2.3.3.zip" version="2.3.3">
        <description>A simple jar project that has some Spring and JPA configuration and an integration test.</description>
    </descriptor>
    <descriptor category="Persistence" id="org.springframework.samples.spring.jpa" kind="template" local="false" name="Simple Spring JPA Utility Project" requires="2.8.0" requiresbundle="org.eclipse.m2e.core" size="15075" url="https://dist.springsource.com/release/STS/help/org.springframework.samples.spring.jpa-2.4.2.zip" version="2.4.2">
        <description>A simple jar project that has some Spring and JPA configuration and an integration test.</description>
    </descriptor>
    <descriptor id="org.springframework.samples.spring.utility" kind="template" local="false" name="Simple Spring Utility Project" requires="[0.0.0,2.8.0)" size="12666" url="https://dist.springsource.com/release/STS/help/org.springframework.samples.spring.utility-2.5.1.zip" version="2.5.1">
        <description>A simple jar project that has some Spring configuration and an integration test</description>
    </descriptor>
    <descriptor id="org.springframework.samples.spring.utility" kind="template" local="false" name="Simple Spring Utility Project" requires="2.8.0" requiresbundle="org.eclipse.m2e.core" size="12684" url="https://dist.springsource.com/release/STS/help/org.springframework.samples.spring.utility-2.6.1.zip" version="2.6.1">
        <description>A simple jar project that has some Spring configuration and an integration test</description>
    </descriptor>
    <descriptor id="org.springframework.samples.petclinic" kind="sample" local="false" name="PetClinic" size="21722686" url="https://dist.springsource.com/release/STS/help/org.springframework.samples.petclinic-2.5.0.20080208-1600.zip" version="2.5.0.20080208-1600">
        <description/>
    </descriptor>
    <descriptor id="org.springframework.samples.springtravel" kind="sample" local="false" name="SpringTravel" size="4409712" url="https://dist.springsource.com/release/STS/help/org.springframework.samples.springtravel-2.5.2.20000702-1000.zip" version="2.5.2.20000702-1000">
        <description/>
    </descriptor>
    <descriptor category="Spring Security" id="org.springframework.security.tutorials.basicsecurity" kind="tutorial" local="false" name="Securing your web application with Spring Security" size="4759272" url="https://dist.springsource.com/release/STS/help/org.springframework.security.tutorials.basicsecurity-1.0.0.zip" version="1.0.0">
        <description>This tutorial shows how to configure simple role-based security for a standard web application.</description>
    </descriptor>
    <descriptor category="Spring Framework" id="org.springframework.tutorial.WhatsNewIn25" kind="tutorial" local="false" name="What's new in Spring 2.5" size="13310" url="https://dist.springsource.com/release/STS/help/org.springframework.tutorial.WhatsNewIn25-1.0.0.zip" version="1.0.0">
        <description>This cheat sheet demonstrates key concepts that are new in Spring 2.5.</description>
        <dependency id="org.springframework.samples.petclinic"/>
    </descriptor>
    <descriptor category="Spring Framework" id="org.springframework.tutorials.addingManagementToYourSpringApplications" kind="tutorial" local="false" name="Adding Management to Your Spring Applications" size="15440" url="https://dist.springsource.com/release/STS/help/org.springframework.tutorials.addingManagementToYourSpringApplications-1.0.0.zip" version="1.0.0">
        <description>This tutorial demonstrates how to instrument your Spring applications for management using Spring, JMX and AOP.</description>
        <dependency id="org.springframework.samples.petclinic"/>
    </descriptor>
    <descriptor category="Spring Framework" id="org.springframework.tutorials.gettingstartedwithspringjdbc" kind="tutorial" local="false" name="Getting Started with Spring JDBC" size="8568468" url="https://dist.springsource.com/release/STS/help/org.springframework.tutorials.gettingstartedwithspringjdbc-1.0.1.zip" version="1.0.1">
        <description>This tutorial shows how to get started using Spring JDBC for simple data access.</description>
    </descriptor>
    <descriptor category="Spring Framework" id="org.springframework.tutorials.jms.creatingmdb" kind="tutorial" local="false" name="Creating JMS-enabled Spring application" size="3675267" url="https://dist.springsource.com/release/STS/help/org.springframework.tutorials.jms.creatingmdb-1.0.0.zip" version="1.0.0">
        <description>This tutorial provides an overview of JMS features with the Spring Framework.</description>
    </descriptor>
    <descriptor category="Spring Framework" id="org.springframework.tutorials.junit.integrationtestingwithjunit4" kind="tutorial" local="false" name="Integration Testing with JUnit 4" size="7429423" url="https://dist.springsource.com/release/STS/help/org.springframework.tutorials.junit.integrationtestingwithjunit4-1.0.0.zip" version="1.0.0">
        <description>This tutorial will walk developers through the process of creating a JUnit 4 integration test.</description>
    </descriptor>
    <descriptor category="Spring Framework" id="org.springframework.tutorials.testing.junit3-legacy" kind="tutorial" local="false" name="Integration Testing with JUnit 3 and Spring" size="7438660" url="https://dist.springsource.com/release/STS/help/org.springframework.tutorials.testing.junit3-legacy-1.0.0.zip" version="1.0.0">
        <description>This tutorial will show you how to implement integration tests using the Spring JUnit 3.8 testing framework.</description>
    </descriptor>
    <descriptor category="Spring Framework" id="org.springframework.tutorials.testing.junit3" kind="tutorial" local="false" name="Integration Testing with JUnit 3 and the Spring TestContext Framework" size="7432757" url="https://dist.springsource.com/release/STS/help/org.springframework.tutorials.testing.junit3-1.0.0.zip" version="1.0.0">
        <description>This tutorial will show you how to implement integration tests using the Spring 2.5+ TestContext framework and JUnit 3.</description>
    </descriptor>
    <descriptor category="Spring Framework" id="org.springframework.tutorials.txmgmt.addingtxmangagement" kind="tutorial" local="false" name="Adding Declarative Transaction Management to Your Spring Applications" size="3939660" url="https://dist.springsource.com/release/STS/help/org.springframework.tutorials.txmgmt.addingtxmangagement-1.0.0.zip" version="1.0.0">
        <description>his tutorial demonstrates how to apply Spring's support for declarative transaction management.</description>
    </descriptor>
    <descriptor category="Spring Framework" id="org.springframework.tutorials.usingstoredprocedures" kind="tutorial" local="false" name="Using Stored Procedures" size="6387472" url="https://dist.springsource.com/release/STS/help/org.springframework.tutorials.usingstoredprocedures-1.0.0.zip" version="1.0.0">
        <description>A tutorial for getting started using stored procedures.</description>
    </descriptor>
    <descriptor category="Spring Web" id="org.springframework.web.tutorials.creatingcontroller" kind="tutorial" local="false" name="Creating a Controller" size="26558" url="https://dist.springsource.com/release/STS/help/org.springframework.web.tutorials.creatingcontroller-1.0.0.zip" version="1.0.0">
        <description>This tutorial will walk developers through the process of creating a @Controller to implement a basic use case end-to-end.</description>
        <dependency id="org.springframework.samples.springtravel"/>
    </descriptor>
    <descriptor category="Spring Web" id="org.springframework.web.tutorials.webprojectoverview" kind="tutorial" local="false" name="Spring Web Development Overview" size="27161" url="https://dist.springsource.com/release/STS/help/org.springframework.web.tutorials.webprojectoverview-1.0.0.zip" version="1.0.0">
        <description>This tutorial provides an overview of web development with the Spring Framework.</description>
        <dependency id="org.springframework.samples.springtravel"/>
    </descriptor>
    <descriptor id="org.springframework.webflow.samples.booking.jsf" kind="sample" local="false" name="Hotel Booking Reference App (Spring MVC + Web Flow + JavaServerFaces version)" size="13644612" url="https://dist.springsource.com/release/STS/help/org.springframework.webflow.samples.booking.jsf-2.0.7.20090423-1700.zip" version="2.0.7.20090423-1700">
        <description/>
    </descriptor>
    <descriptor category="Spring Web Flow" id="org.springframework.webflow.tutorial.GetStarted" kind="tutorial" local="false" name="Get Started with Spring Web Flow" size="8709" url="https://dist.springsource.com/release/STS/help/org.springframework.webflow.tutorial.GetStarted-1.0.0.zip" version="1.0.0">
        <description>Learn how to use the Web Flow framework in your Spring application.</description>
        <dependency id="org.springframework.webflow.samples.booking.jsf"/>
        <dependency id="cohttp://m.springsource.sts.org.apache.tomcat"/>
    </descriptor>
    <descriptor category="Spring Web Services" id="org.springframework.webservices.tutorials.creatingcontroller" kind="tutorial" local="false" name="Creating a contract-first web service" size="9741990" url="https://dist.springsource.com/release/STS/help/org.springframework.webservices.tutorials.creatingcontroller-1.0.0.zip" version="1.0.0">
        <description>This tutorial shows you how to create a contract-first web service with Spring-WS. The contract-first approach is an industry recognized best practice. In short it means we'll design an XML contract first and a Java implementation second.</description>
        <dependency id="cohttp://m.springsource.sts.org.apache.tomcat"/>
    </descriptor>
    <descriptor category="Integration" id="org.springframework.integration.sts.template.standalone.simple" kind="template" local="false" name="Spring Integration Project (Standalone) - Simple" requires="[3.0.0,4.0)" requiresbundle="org.eclipse.m2e.core" size="9500" url="https://raw.github.com/SpringSource/spring-integration-templates/master/si-sts-templates/builds/si-template-standalone-simple-1.0.1.RELEASE.zip" version="1.0.1.RELEASE">
        <description>Creates a Spring Integration project that runs as a standalone Java application using core components only.</description>
    </descriptor>
    <descriptor category="Integration" id="org.springframework.integration.sts.template.standalone" kind="template" local="false" name="Spring Integration Project (Standalone) - File" requires="[3.0.0,4.0)" requiresbundle="org.eclipse.m2e.core" size="12100" url="https://raw.github.com/SpringSource/spring-integration-templates/master/si-sts-templates/builds/si-template-standalone-1.0.1.RELEASE.zip" version="1.0.1.RELEASE">
        <description>Creates a Spring Integration project that runs as a standalone Java application using file polling and file output.</description>
    </descriptor>
    <descriptor category="Integration" id="org.springframework.integration.sts.template.war" kind="template" local="false" name="Spring Integration Project (War)" requires="[3.0.0,4.0)" requiresbundle="org.eclipse.m2e.core" size="155900" url="https://raw.github.com/SpringSource/spring-integration-templates/master/si-sts-templates/builds/si-template-war-1.0.1.RELEASE.zip" version="1.0.1.RELEASE">
        <description>Creates a Spring Integration project that runs within a servlet container. Uses the Spring Integration Twitter adapter.</description>
    </descriptor>
    <descriptor category="Integration" id="org.springframework.integration.sts.template.adapter" kind="template" local="false" name="Spring Integration Adapter Template Project" requires="[3.2.0,4.0)" requiresbundle="org.springsource.ide.eclipse.gradle.core" size="122100" url="https://raw.github.com/SpringSource/spring-integration-templates/master/si-sts-templates/builds/si-template-adapter-1.0.1.RELEASE.zip" version="1.0.1.RELEASE">
        <description>Creates a Spring Integration Adapter Template. Requires Gradle Support.</description>
    </descriptor>
    <descriptor category="Integration" id="org.springframework.integration.sts.template.adapter" kind="template" local="false" name="Spring Integration Adapter Template Project" requires="[3.0.0,3.2)" size="118119" url="https://raw.github.com/SpringSource/spring-integration-templates/master/si-sts-templates/builds/si-template-adapter-1.0.0.M4.zip" version="1.0.0.M4">
        <description>Creates a Spring Integration Adapter Template. Requires Gradle Support. Deprecated, please update STS to version 3.2+ for the latest template version</description>
    </descriptor>
    <descriptor id="org.springframework.integration.sts.template.standalone.simple" kind="template" local="false" name="Spring Integration Project (Standalone) - Simple" requires="[0.0.0,3.0.0)" size="8390" url="https://raw.github.com/SpringSource/spring-integration-templates/master/si-sts-templates/builds/si-template-standalone-simple-1.0.0.M2.zip" version="1.0.0.M2">
        <description>Creates a Spring Integration project that runs as a standalone Java application using core components only. Deprecated, please update STS to version 3.2+ for the latest template version</description>
    </descriptor>
    <descriptor id="org.springframework.integration.sts.template.standalone" kind="template" local="false" name="Spring Integration Project (Standalone) - File" requires="[0.0.0,3.0.0)" size="10258" url="https://raw.github.com/SpringSource/spring-integration-templates/master/si-sts-templates/builds/si-template-standalone-1.0.0.M2.zip" version="1.0.0.M2">
        <description>Creates a Spring Integration project that runs as a standalone Java application using file polling and file output. Deprecated, please update STS to version 3.2+ for the latest template version</description>
    </descriptor>
    <descriptor id="org.springframework.integration.sts.template.war" kind="template" local="false" name="Spring Integration Project (War)" requires="[0.0.0,3.0.0)" size="56242" url="https://raw.github.com/SpringSource/spring-integration-templates/master/si-sts-templates/builds/si-template-war-1.0.0.M2.zip" version="1.0.0.M2">
        <description>Creates a Spring Integration project that runs within a servlet container. Uses the Spring Integration Twitter adapter. Deprecated, please update STS to version 3.2+ for the latest template version</description>
    </descriptor>
    <descriptor id="org.springframework.templates.mvc" kind="template" local="true" name="Spring MVC Project" requiresbundle="org.eclipse.m2e.core" size="0" version="3.2.2">
        <description>A new Spring MVC web application development project</description>
    </descriptor>
    <descriptor id="org.springframework.templates.mvc" kind="template" local="true" name="Spring MVC Project" requiresbundle="org.eclipse.m2e.core" size="0" version="3.2.2">
        <description>A new Spring MVC web application development project</description>
    </descriptor>
</descriptors>

 

 

Spring MVC Project 수동 생성


 

스프링에서 MVC Project Template는 미리 구성된 프로젝트 구조와 설정을 기본으로 제공하여 개발을 용이하게 해준다.

기본 프로젝트 '구조'와 Spring MVC Project에 사용되는 필수요소 '라이브러리 의존성', 'web.xml', 'Spring 설정파일' 등으로 구성되어 있다. 

 

전자정부프레임워크에서 'Spring MVC Project' Template을 수동으로 생성해보겠다. 

 

 

1. Dynamic Web Project 생성


> New > Dynamic Web Project

 

나는 초기설정을 해둬서 Target runtime란에 이미 톰캣으로 설정되어 있다.  

다르게 설정되어 있다면 초기설정 필요

 

 

 

 

 

2. Maven 프로젝트로 변경 및 스프링 프레임워크 의존성 추가


 

프로젝트 우클릭 > Configure > Convert to Maven Project > finish

 

Maven은 프로젝트의 전체적인 사이클 및 라이브러리를 관리하는 도구이다.  필요한 라이브러리를 pom.xml 파일을 통해 지정하거나 자동으로 다운로드 할 수 있다.

*협업 과정에서 'pom.xml' 파일이 공유되기 때문에 팀원들이 동일한 개발 환경(라이브러리)에서 작업이 가능하다.   

 

 

https://mvnrepository.com/

위 사이트에서 spring web을 검색 후 

Spring Web과 Spring Web MVC를 클릭해 복사해서 pom.xml 파일에 붙여넣으면 된다.

 

(나는 탬플릿 생성시 기본 pom.xml 파일을 참고하여 입력했다.)

플러그인 부분은 이미 설정된 maven이 있어서 제외하고 아래 코드를 추가입력함.

 

	<properties>
		<java-version>11</java-version>
		<org.springframework-version>5.2.5.RELEASE</org.springframework-version>
		<org.aspectj-version>1.6.10</org.aspectj-version>
		<org.slf4j-version>1.6.6</org.slf4j-version>
	</properties>
	<dependencies>
		<!-- Spring -->
		<dependency>
			<groupId>org.springframework</groupId>
			<artifactId>spring-context</artifactId>
			<version>${org.springframework-version}</version>
			<exclusions>
				<!-- Exclude Commons Logging in favor of SLF4j -->
				<exclusion>
					<groupId>commons-logging</groupId>
					<artifactId>commons-logging</artifactId>
				</exclusion>
			</exclusions>
		</dependency>
		<dependency>
			<groupId>org.springframework</groupId>
			<artifactId>spring-webmvc</artifactId>
			<version>${org.springframework-version}</version>
		</dependency>

		<!-- AspectJ -->
		<dependency>
			<groupId>org.aspectj</groupId>
			<artifactId>aspectjrt</artifactId>
			<version>${org.aspectj-version}</version>
		</dependency>

		<!-- Logging -->
		<dependency>
			<groupId>org.slf4j</groupId>
			<artifactId>slf4j-api</artifactId>
			<version>${org.slf4j-version}</version>
		</dependency>
		<dependency>
			<groupId>org.slf4j</groupId>
			<artifactId>jcl-over-slf4j</artifactId>
			<version>${org.slf4j-version}</version>
			<scope>runtime</scope>
		</dependency>
		<dependency>
			<groupId>org.slf4j</groupId>
			<artifactId>slf4j-log4j12</artifactId>
			<version>${org.slf4j-version}</version>
			<scope>runtime</scope>
		</dependency>
		<dependency>
			<groupId>log4j</groupId>
			<artifactId>log4j</artifactId>
			<version>1.2.15</version>
			<exclusions>
				<exclusion>
					<groupId>javax.mail</groupId>
					<artifactId>mail</artifactId>
				</exclusion>
				<exclusion>
					<groupId>javax.jms</groupId>
					<artifactId>jms</artifactId>
				</exclusion>
				<exclusion>
					<groupId>com.sun.jdmk</groupId>
					<artifactId>jmxtools</artifactId>
				</exclusion>
				<exclusion>
					<groupId>com.sun.jmx</groupId>
					<artifactId>jmxri</artifactId>
				</exclusion>
			</exclusions>
			<scope>runtime</scope>
		</dependency>

		<!-- @Inject -->
		<dependency>
			<groupId>javax.inject</groupId>
			<artifactId>javax.inject</artifactId>
			<version>1</version>
		</dependency>

		<!-- Servlet -->
		<dependency>
			<groupId>javax.servlet</groupId>
			<artifactId>servlet-api</artifactId>
			<version>2.5</version>
			<scope>provided</scope>
		</dependency>
		<dependency>
			<groupId>javax.servlet.jsp</groupId>
			<artifactId>jsp-api</artifactId>
			<version>2.1</version>
			<scope>provided</scope>
		</dependency>
		<dependency>
			<groupId>javax.servlet</groupId>
			<artifactId>jstl</artifactId>
			<version>1.2</version>
		</dependency>

		<!-- Test -->
		<dependency>
			<groupId>junit</groupId>
			<artifactId>junit</artifactId>
			<version>4.7</version>
			<scope>test</scope>
		</dependency>
	</dependencies>

 

 

 

 

* 직접 다운받아 복사해올 때 참고

 

 

 

 

 

*저장 후 좌측 Maven Dependencies를 확인하면 추가한 라이브러리들을 확인할 수 있다.

이 후 Maven Update를 실행한다.

 

 

 

 

 

3. xml 파일 생성


 

Spring Project에서 xml 파일은 애플리케이션 컨텍스트를 설정하거나 웹 애플리케이션 구성을 지정하는데 사용된다.

*web.xml - 웹 서버에서 사용할 기본 설정을 입력하는 파일

 

 

1) web.xml 파일 생성

 

'/src/main/webapp/WEB-INF/' 경로에 

"web.xml" 파일을 생성한다.

web.xml 파일은 root-context.xml, servlet-context.xml 파일을 참조한다.

 

프로젝트 우클릭 > Java EE Tools > Generate Deployment Descriptor Stub

*파일 생성시 에러가 난다면 아래 코드처럼 java  > Java로 변경

<?xml version="1.0" encoding="UTF-8"?>
<web-app version="2.5" xmlns="http://java.sun.com/xml/ns/javaee"
	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
	xsi:schemaLocation="http://Java.sun.com/xml/ns/javaee https://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">

	<!-- The definition of the Root Spring Container shared by all Servlets and Filters -->
	<context-param>
		<param-name>contextConfigLocation</param-name>
		<param-value>/WEB-INF/spring/root-context.xml</param-value>
	</context-param>
	
	<!-- Creates the Spring Container shared by all Servlets and Filters -->
	<listener>
		<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
	</listener>

	<!-- Processes application requests -->
	<servlet>
		<servlet-name>appServlet</servlet-name>
		<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
		<init-param>
			<param-name>contextConfigLocation</param-name>
			<param-value>/WEB-INF/spring/appServlet/servlet-context.xml</param-value>
		</init-param>
		<load-on-startup>1</load-on-startup>
	</servlet>
		
	<servlet-mapping>
		<servlet-name>appServlet</servlet-name>
		<url-pattern>/</url-pattern>
	</servlet-mapping>
	
	<filter>
		<filter-name>encodingFilter</filter-name>
		<filter-class>org.springframework.web.filter.CharacterEncodingFilter</filter-class>
		<init-param>
			<param-name>encoding</param-name>
			<param-value>UTF-8</param-value>
		</init-param>
		<init-param>
			<param-name>forceEncoding</param-name>
			<param-value>true</param-value>
		</init-param>
	</filter>
	<filter-mapping>
		<filter-name>encodingFilter</filter-name>
		<url-pattern>/*</url-pattern>
	</filter-mapping>

</web-app>

 

 

 

2) root-context.xml 파일 생성

 

/src/main/webapp/WEB-INF/spring/' 경로에 'root-context.xml' 파일 생성

본 파일이 위치할 폴더 우클릭 > New > Other > xml 검색 후 파일 생성

 

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
	xmlns:tx="http://www.springframework.org/schema/tx"
	xmlns:mybatis-spring="http://mybatis.org/schema/mybatis-spring"
	xsi:schemaLocation="http://mybatis.org/schema/mybatis-spring http://mybatis.org/schema/mybatis-spring-1.2.xsd
	http://www.springframework.org/schema/beans https://www.springframework.org/schema/beans/spring-beans.xsd
	http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-3.0.xsd">

	<!-- Root Context: defines shared resources visible to all other web components -->
	
</beans>

 

 

 

3) servlet-context.xml 파일 생성

 

/src/main/webapp/WEB-INF/spring/appServlet/ 경로에 'servlet-context.xml' 파일 생성

 

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

	<!-- DispatcherServlet Context: defines this servlet's request-processing infrastructure -->
	
	<!-- Enables the Spring MVC @Controller programming model -->
	<annotation-driven />

	<!-- Handles HTTP GET requests for /resources/** by efficiently serving up static resources in the ${webappRoot}/resources directory -->
	<resources mapping="/resources/**" location="/resources/" />

	<!-- Resolves views selected for rendering by @Controllers to .jsp resources in the /WEB-INF/views directory -->
	<beans:bean class="org.springframework.web.servlet.view.InternalResourceViewResolver">
		<beans:property name="prefix" value="/WEB-INF/views/" />
		<beans:property name="suffix" value=".jsp" />
	</beans:bean>
	
</beans:beans>

 

 

 

참고 페이지 

https://wildeveloperetrain.tistory.com/m/347

 

+ Recent posts