요즘 현업을 시작하면서 

 

환경변수 세팅 , 세팅 , 세팅 .. 하느냐고

 

너무 바쁜것 같다. 세팅이 진짜 절반인것같다. 

 

그리고 스프링 부트스프링은 확실하게 다르다.

 

(나는 이 둘이 비슷하다라고 생각되지 않는다.)


결과값

 

 

시작

 

 

 

 

 

기본적으로 프로젝트를 생성하면,

 

여기까지는 기본적으로 만들어져있을 것이다.

 

이제 웹 페이지를 띄우기 위한 방법이 필요한데

 

⭐⭐⭐⭐⭐

 

Spring Boot는 Spring과 다르게 Server가 자체적으로

 

내장 되어있기 때문에 Server을 껐다 켰다 할 필요가 없다. 

 

application.properties

 

 

 

 

server.address=0.0.0.0
server.servlet.context-path=/
server.port=8080

spring.mvc.view.prefix= /WEB-INF/views/
spring.mvc.view.suffix= .jsp

#Datasource Configuration
spring.datasource.hikari.maximum-pool-size=4
spring.datasource.url=jdbc:postgresql://localhost:5432/postgres
spring.datasource.username=[본인해당아이디]
spring.datasource.password=[본인비밀번호]



#그리고 여긴 샵이 주석임

 

신기한건 Spring의 root-context / Servlet 에서 DB사용과 

 

서버에대한 주소 Path, 이런것을 다 

 

 

 

 

⭐⭐⭐⭐⭐

 

Application.properties 여기다가 선언해주는것이다.

 

정말 당황 스러웠다. 스프링 레거시는 알아서 다 적어주는데..

 

+ 디비연결 안되면 웹 또는 콘솔에 DB연결하라는 Error 계속 뜰것이다.

 

 

TestController.java

 

 

package com.example.test;

import javax.sql.DataSource;

import org.springframework.boot.jdbc.DataSourceBuilder;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;

@Controller
public class TestController {

	
	@RequestMapping(value = "/index")
	public String test() throws Exception {

		return "index";
	}

}

 

 

이건 그나마 Spring이랑 비슷한 부분인것 같다. 

 

Controller를 통해서 Mapping 해주는 역할 (RequestMapping 오랜만에 봐서 반갑다.)

 

 

 

pom.xml

 

 

		<!--  jsp를 연결시켜주는 tag s -->
		<dependency>
			<groupId>org.apache.tomcat.embed</groupId>
			<artifactId>tomcat-embed-jasper</artifactId>
		</dependency>
		<!--  jsp를 연결시켜주는 tag e -->

 

 

pom.xml 에 이것까지 선언해주면 아마 Error = 404 는 일어날일 없을 것이다.

 

index.jsp

 

<%@ page language="java" contentType="text/html; charset=EUC-KR"   pageEncoding="EUC-KR"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="EUC-KR">

<title>오픈레이어스 예제</title>

  <style>
    .map {
      height: 960px;
      width: 100%;
    }
    
  </style>	
	
</head>

<body>
	
		<h1>헬로월드!!!!</h1>
		<h1>헬로월드!!!!</h1>
	

</body>
</html>

 

 

이제 마지막이다 jsp파일만 생성해주면 된다

 

난 간단하게 index.jsp 로 지었다. 

 

 

폴더 잘 만들어 주도록 하자 아니면 index.jsp 파일을 못찾는다.

 

 

 

 

 

자 그럼 여기까지 jsp 페이지 띄우는것까지는 

 

 

Github 잔디가 안심어진다면 아래 참조

 

https://chocoboy.tistory.com/165

 


 

 

To be continue..

복사했습니다!