https://cafe.naver.com/hamminglab/19611
window > properties 에서 web이 보이지않는다.
이럴때는?
Help > Eclipse marketplace > eclipse web 검색 > eclipse enterprise 다운로드
1. 초기설정.
bundle.gradle파일 구성. 프로젝트 생성시에 war타입을 선택하지 않았다면, 아래 gradle 파일에서 id 'war'를 꼭 써주기!
plugins {
id 'java'
id 'war'
id 'org.springframework.boot' version '2.7.18'
id 'io.spring.dependency-management' version '1.1.4'
}
group = 'co.kr.chunjae'
version = '0.0.1-SNAPSHOT'
java {
sourceCompatibility = '11'
}
configurations {
compileOnly {
extendsFrom annotationProcessor
}
}
repositories {
mavenCentral()
}
dependencies {
implementation 'org.springframework.boot:spring-boot-starter-web'
compileOnly 'org.projectlombok:lombok'
providedRuntime 'org.springframework.boot:spring-boot-starter-tomcat'
developmentOnly 'org.springframework.boot:spring-boot-devtools'
annotationProcessor 'org.projectlombok:lombok'
testImplementation 'org.springframework.boot:spring-boot-starter-test'
implementation 'org.apache.tomcat.embed:tomcat-embed-jasper'
implementation 'javax.servlet:jstl'
}
tasks.named('test') {
useJUnitPlatform()
}
server.port=8094
spring.mvc.view.prefix=/WEB-INF/views/
spring.mvc.view.suffix=.jsp
server:
port: 8094
spring:
mvc:
view:
prefix: /WEB-INF/views/
suffix: .jsp
package kr.co.chunjae.controller;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
@Controller
public class TestController {
@RequestMapping(value = "/")
public String home() {
System.out.println("TestController home");
return "index";
}
}
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<!doctype html>
<html lang="ko">
<head>
<meta charset="UTF-8">
<title>JSP 테스트</title>
</head>
<body>
JSP 테스트
</body>
</html>
프로젝트를 실행할때 스프링부트는 서버를 선택하지 않고 Java 처럼 main( ) 함수를 실행
실행화면
https://wildeveloperetrain.tistory.com/26
https://medium.com/sjk5766/bean%EA%B3%BC-component-%EC%B0%A8%EC%9D%B4-96a8d0533bfd
https://madplay.github.io/post/why-constructor-injection-is-better-than-field-injection