개발 환경 설정 및 툴 사용법

프로젝트 개발을 위한 환경설정 - Spring Boot, 의존성(pom.xml), 및 빌드툴 설정

letsDoDev 2023. 10. 19. 15:08

- IDE : 이클립스

- 빌드툴: Maven

- Framework : Spring Boot 2.x

- Java : 11

- DB : Oracle 11E

- ORM : Mybatis (JPA는 추후 사용해보고 싶어서 일단 추가했음)

 

특이사항 )

jsp 사용을 원해 jsp 사용과 관련된 의존성을 추가하였으나 spring boot에서는 Thymeleaf를 권장한다고 해서 실제로 사용하지는 않음

 

① 스프링 이니셜라이저

 

② pom.xml

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
	xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
	<modelVersion>4.0.0</modelVersion>
	<parent>
		<groupId>org.springframework.boot</groupId>
		<artifactId>spring-boot-starter-parent</artifactId>
		 <version>2.0.0.RELEASE</version>
		<relativePath/> <!-- lookup parent from repository -->
	</parent>
	<groupId>com.springboot.myplanner</groupId>
	<artifactId>first-springboot-project</artifactId>
	<version>0.0.1-SNAPSHOT</version>
	<name>first-springboot-project</name>
	<description>myplanner project for Spring Boot</description>
	<properties>
		<java.version>11</java.version>
	</properties>
	<dependencies>
		<dependency>
			<groupId>org.springframework.boot</groupId>
			<artifactId>spring-boot-starter-data-jpa</artifactId>
		</dependency>
		<dependency>
			<groupId>org.springframework.boot</groupId>
			<artifactId>spring-boot-starter-security</artifactId>
		</dependency>
		<dependency>
			<groupId>org.springframework.boot</groupId>
			<artifactId>spring-boot-starter-validation</artifactId>
		</dependency>
		<dependency>
			<groupId>org.springframework.boot</groupId>
			<artifactId>spring-boot-starter-web</artifactId>
		</dependency>

		<dependency>
			<groupId>org.springframework.boot</groupId>
			<artifactId>spring-boot-devtools</artifactId>
			<scope>runtime</scope>
			<optional>true</optional>
		</dependency>
		<!-- 오라클 연동을 위한 추가 부분 javax.xml.bind  -->
		<dependency>
		    <groupId>javax.xml.bind</groupId>
		    <artifactId>jaxb-api</artifactId>
		    <!-- <version>2.3.1</version> --> <!-- JAXB API 버전에 따라 변경 가능 -->
		</dependency>
		
		<dependency>
            <groupId>oracle.jdbc</groupId>
            <artifactId>OracleDriver</artifactId>
		    <version>19.8.0.0</version>
	        <scope>system</scope>
            <systemPath>${basedir}/src/main/webapp/WEB-INF/lib/ojdbc8.jar</systemPath>
		</dependency>
		
		<dependency>
			<groupId>org.springframework.boot</groupId>
			<artifactId>spring-boot-starter-test</artifactId>
			<scope>test</scope>
		</dependency>
		<dependency>
			<groupId>org.springframework.security</groupId>
			<artifactId>spring-security-test</artifactId>
			<scope>test</scope>
		</dependency>
		<!-- lombok  -->
		<dependency>
		    <groupId>org.projectlombok</groupId>
		    <artifactId>lombok</artifactId>
		    <optional>true</optional>
		</dependency>
		<!-- ibatis  -->
		<dependency>
        	<groupId>org.mybatis.spring.boot</groupId>
        	<artifactId>mybatis-spring-boot-starter</artifactId>
        	<version>2.1.4</version>
		</dependency>
		
		<!-- Thymeleaf  -->
	   <dependency>
       		 <groupId>org.springframework.boot</groupId>
     	  	 <artifactId>spring-boot-starter-thymeleaf</artifactId>
   		 </dependency>
   		 
		<!-- jsp  -->		
		<dependency>
		       <groupId>javax.servlet</groupId>
		       <artifactId>jstl</artifactId>
		</dependency>
       <dependency>
            <groupId>org.apache.tomcat.embed</groupId>
            <artifactId>tomcat-embed-jasper</artifactId>
            <scope>provided</scope>
        </dependency>

 		<!-- https://mvnrepository.com/artifact/org.springframework.boot/spring-boot-starter-tomcat -->
		<dependency>
		    <groupId>org.springframework.boot</groupId>
		    <artifactId>spring-boot-starter-tomcat</artifactId>
		    <scope>provided</scope>
		</dependency>
		
		<!-- etc  -->
	    <dependency>
        	<groupId>commons-logging</groupId>
       		<artifactId>commons-logging</artifactId>
      		<version>1.1.1</version>
    	</dependency>
		
		</dependencies>
	<build>
		<plugins>
			<plugin>
				<groupId>org.springframework.boot</groupId>
				<artifactId>spring-boot-maven-plugin</artifactId>
			</plugin>
		</plugins>
	</build>

</project>

 

③ application.properties

# server
server.port=8090

# view
spring.thymeleaf.prefix=classpath:/templates/
spring.thymeleaf.suffix=.html

# encoding
spring.http.encoding.charset=UTF-8
spring.servlet.filter.character.encoding.enabled=true
spring.servlet.filter.character.encoding.force-request=true
spring.servlet.filter.character.encoding.force-response=true
spring.servlet.filter.character.encoding.encoding=UTF-8
spring.servlet.filter.character.encoding.force=true

# resources 
spring.mvc.static-path-pattern=/resources/**

# database
spring.datasource.driver-class-name=oracle.jdbc.OracleDriver
spring.datasource.url=jdbc:oracle:thin:@localhost:1521:xe
spring.datasource.username=myplanner
spring.datasource.password=myplanner007$

# mybatis
mybatis.mapper-locations=classpath:mapper/*.xml

# url
server.servlet.context-path=/