프로젝트 생성
의존성 추가
추가적인 의존성 추가
시큐리티 태그 라이브러리, JSP 템플릿 엔진, JSTL 을 추가한다.
아래의 사이트에 가서 검색을 통해 설치할 수 있다.
하지만 일일이 찾기 귀찮기 때문에 메타코딩님 블로그에 가서 복사해왔다.
https://getinthere.tistory.com/16
스프링부트 with JPA 블로그 2강 - 의존성 설정
1. Spring Boot DevTools https://docs.spring.io/spring-boot/docs/1.5.16.RELEASE/reference/html/using-boot-devtools.html 20. Developer tools Applications that use spring-boot-devtools will automatically restart whenever files on the classpath change. This ca
getinthere.tistory.com
복사해온 의존성을 pom.xml의 dependencys태그 사이에 추가하고 ctrl+s 로 저장한다. -> 저장하면 자동으로 설치가 됨
spring-boot-starter-data-jpa, spring-boot-starter-security,mysql-connector-j,spring-security-taglibs 는 아직 쓸 라이브러리가 아니기 때문에 주석처리한다.
<?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.7.17</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<groupId>com.lwj</groupId>
<artifactId>blog</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>blog</name>
<description>My First Blog Project</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-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-devtools</artifactId>
<scope>runtime</scope>
<optional>true</optional>
</dependency>
<!--
<dependency>
<groupId>com.mysql</groupId>
<artifactId>mysql-connector-j</artifactId>
<scope>runtime</scope>
</dependency>
-->
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<optional>true</optional>
</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>
<!-- 추가 라이브러리 시작 -->
<!-- 시큐리티 태그 라이브러리 -->
<!--
<dependency>
<groupId>org.springframework.security</groupId>
<artifactId>spring-security-taglibs</artifactId>
</dependency>
-->
<!-- JSP 템플릿 엔진 -->
<dependency>
<groupId>org.apache.tomcat.embed</groupId>
<artifactId>tomcat-embed-jasper</artifactId>
</dependency>
<!-- JSTL -->
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>jstl</artifactId>
</dependency>
<!-- 추가 라이브러리 끝 -->
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<configuration>
<image>
<builder>paketobuildpacks/builder-jammy-base:latest</builder>
</image>
<excludes>
<exclude>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
</exclude>
</excludes>
</configuration>
</plugin>
</plugins>
</build>
</project>
테스트해보자
혹시 이 오류가 뜬다면 이 서버를 구동할때 8080포트를 사용하는데 다른곳에서 이미 사용중이라 쓸 수 없다는 뜻이다.
즉, 포트번호를 바꿔줘야한다.
-> 프로젝트 내의 application.properties에 가서 포트를 변경해준다.
크롬에서도 확인해보자
url 창에 http://localhost:8001/test/hello 입력!!
참고 유튜브 (메타코딩님 강의)
https://youtu.be/rpcoHCXgGnQ?si=mmR6rLM93F0oZeH5