Skip to content

Commit dc2fd96

Browse files
committed
6주차 요구사항 0단계
1 parent 699f385 commit dc2fd96

26 files changed

+861
-275
lines changed

build.gradle

Lines changed: 21 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1,53 +1,40 @@
11
plugins {
2+
id 'org.springframework.boot' version '2.7.17' // 스프링 부트 플러그인 적용
3+
id 'io.spring.dependency-management' version '1.0.15.RELEASE' // 의존성 관리 플러그인
24
id 'java'
3-
id 'idea'
45
}
56

6-
idea {
7-
module {
8-
inheritOutputDirs = false
9-
outputDir = file('./webapp/WEB-INF/classes')
10-
}
11-
}
12-
13-
group 'org.example'
14-
version '1.0-SNAPSHOT'
7+
group = 'org.example'
8+
version = '1.0-SNAPSHOT'
9+
sourceCompatibility = '11' // 사용하는 자바 버전에 맞게 설정 (예: 11)
1510

1611
repositories {
1712
mavenCentral()
1813
}
1914

20-
ext {
21-
springVersion = "5.1.8.RELEASE"
22-
tomcatVersion = '8.5.42'
23-
}
24-
2515
dependencies {
26-
testImplementation 'org.junit.jupiter:junit-jupiter-api:5.8.1'
27-
testImplementation "org.springframework:spring-test:$springVersion"
28-
testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine:5.8.1'
16+
// 1. Spring Boot Web Starter
17+
implementation 'org.springframework.boot:spring-boot-starter-web'
2918

30-
implementation("org.springframework:spring-jdbc:$springVersion")
31-
implementation("org.springframework:spring-web:$springVersion")
32-
implementation "org.reflections:reflections:0.10.2"
19+
// 2. Spring Boot Data JPA Starter
20+
implementation 'org.springframework.boot:spring-boot-starter-data-jpa'
3321

34-
implementation("org.apache.commons:commons-dbcp2:2.6.0")
22+
// 3. JSP 템플릿 엔진 사용을 위한 의존성
23+
implementation 'org.apache.tomcat.embed:tomcat-embed-jasper'
24+
implementation 'javax.servlet:jstl:1.2'
3525

36-
runtimeOnly("com.h2database:h2:2.1.214")
37-
runtimeOnly('mysql:mysql-connector-java:8.0.28')
26+
// 4. 데이터베이스 드라이버 (H2, MySQL 등 필요한 것 사용)
27+
runtimeOnly 'com.h2database:h2'
28+
runtimeOnly 'mysql:mysql-connector-java'
3829

39-
implementation("org.apache.tomcat.embed:tomcat-embed-core:$tomcatVersion")
40-
implementation("org.apache.tomcat.embed:tomcat-embed-logging-juli:8.5.2")
41-
implementation("org.apache.tomcat.embed:tomcat-embed-jasper:$tomcatVersion")
42-
implementation group: 'javax.servlet', name: 'jstl', version: '1.2'
43-
implementation 'com.fasterxml.jackson.core:jackson-databind:2.12.7.1'
30+
// 5. Lombok (선택 사항이지만 강력히 추천)
31+
compileOnly 'org.projectlombok:lombok'
32+
annotationProcessor 'org.projectlombok:lombok'
33+
34+
// 6. Spring Boot Test Starter
35+
testImplementation 'org.springframework.boot:spring-boot-starter-test'
4436
}
4537

4638
test {
4739
useJUnitPlatform()
48-
}
49-
50-
java {
51-
sourceCompatibility = JavaVersion.VERSION_1_8
52-
targetCompatibility = JavaVersion.VERSION_1_8
5340
}

java-webMVC.ipr

Lines changed: 555 additions & 91 deletions
Large diffs are not rendered by default.

java-webMVC.iws

Lines changed: 54 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,32 @@
55
</component>
66
<component name="ChangeListManager">
77
<list default="true" id="b8532e5e-d8f5-4e8c-a002-746704734daf" name="Changes" comment="">
8-
<change beforePath="$PROJECT_DIR$/webapp/qna/show.jsp" beforeDir="false" afterPath="$PROJECT_DIR$/webapp/qna/show.jsp" afterDir="false" />
8+
<change afterPath="$PROJECT_DIR$/src/main/java/jwp/controller/UserController.java" afterDir="false" />
9+
<change afterPath="$PROJECT_DIR$/src/main/webapp/js/scripts.js" afterDir="false" />
10+
<change beforePath="$PROJECT_DIR$/build.gradle" beforeDir="false" afterPath="$PROJECT_DIR$/build.gradle" afterDir="false" />
11+
<change beforePath="$PROJECT_DIR$/java-webMVC.ipr" beforeDir="false" afterPath="$PROJECT_DIR$/java-webMVC.ipr" afterDir="false" />
12+
<change beforePath="$PROJECT_DIR$/java-webMVC.iws" beforeDir="false" afterPath="$PROJECT_DIR$/java-webMVC.iws" afterDir="false" />
13+
<change beforePath="$PROJECT_DIR$/src/main/java/WebServerLauncher.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/java/WebServerLauncher.java" afterDir="false" />
14+
<change beforePath="$PROJECT_DIR$/src/main/java/core/jdbc/JdbcTemplate.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/java/core/jdbc/JdbcTemplate.java" afterDir="false" />
15+
<change beforePath="$PROJECT_DIR$/src/main/java/jwp/dao/UserDao.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/java/jwp/dao/UserDao.java" afterDir="false" />
16+
<change beforePath="$PROJECT_DIR$/src/main/java/jwp/model/User.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/java/jwp/model/User.java" afterDir="false" />
17+
<change beforePath="$PROJECT_DIR$/webapp/WEB-INF/.gitignore" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/webapp/WEB-INF/.gitignore" afterDir="false" />
18+
<change beforePath="$PROJECT_DIR$/webapp/css/styles.css" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/webapp/css/styles.css" afterDir="false" />
19+
<change beforePath="$PROJECT_DIR$/webapp/css/styles2.css" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/webapp/css/styles2.css" afterDir="false" />
20+
<change beforePath="$PROJECT_DIR$/webapp/favicon.ico" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/webapp/favicon.ico" afterDir="false" />
21+
<change beforePath="$PROJECT_DIR$/webapp/home.jsp" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/webapp/home.jsp" afterDir="false" />
22+
<change beforePath="$PROJECT_DIR$/webapp/img/KUIT.png" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/webapp/img/KUIT.png" afterDir="false" />
23+
<change beforePath="$PROJECT_DIR$/webapp/img/picture.jpeg" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/webapp/img/picture.jpeg" afterDir="false" />
24+
<change beforePath="$PROJECT_DIR$/webapp/include/header.jspf" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/webapp/include/header.jspf" afterDir="false" />
25+
<change beforePath="$PROJECT_DIR$/webapp/include/navigation.jspf" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/webapp/include/navigation.jspf" afterDir="false" />
26+
<change beforePath="$PROJECT_DIR$/webapp/js/scripts.js" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/resources/application.properties" afterDir="false" />
27+
<change beforePath="$PROJECT_DIR$/webapp/qna/form.jsp" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/webapp/qna/form.jsp" afterDir="false" />
28+
<change beforePath="$PROJECT_DIR$/webapp/qna/show.jsp" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/webapp/qna/show.jsp" afterDir="false" />
29+
<change beforePath="$PROJECT_DIR$/webapp/user/form.jsp" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/webapp/user/form.jsp" afterDir="false" />
30+
<change beforePath="$PROJECT_DIR$/webapp/user/list.jsp" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/webapp/user/list.jsp" afterDir="false" />
31+
<change beforePath="$PROJECT_DIR$/webapp/user/login.jsp" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/webapp/user/login.jsp" afterDir="false" />
32+
<change beforePath="$PROJECT_DIR$/webapp/user/loginFailed.jsp" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/webapp/user/loginFailed.jsp" afterDir="false" />
33+
<change beforePath="$PROJECT_DIR$/webapp/user/updateForm.jsp" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/webapp/user/updateForm.jsp" afterDir="false" />
934
</list>
1035
<option name="SHOW_DIALOG" value="false" />
1136
<option name="HIGHLIGHT_CONFLICTS" value="true" />
@@ -118,28 +143,33 @@
118143
<option name="hideEmptyMiddlePackages" value="true" />
119144
<option name="showLibraryContents" value="true" />
120145
</component>
121-
<component name="PropertiesComponent">{
122-
&quot;keyToString&quot;: {
123-
&quot;Application.WebServerLauncher.executor&quot;: &quot;Run&quot;,
124-
&quot;Gradle.KUIT6_Server-webMVC.executor&quot;: &quot;Run&quot;,
125-
&quot;JUnit.UserTest.executor&quot;: &quot;Run&quot;,
126-
&quot;RunOnceActivity.ShowReadmeOnStart&quot;: &quot;true&quot;,
127-
&quot;git-widget-placeholder&quot;: &quot;week5junyong&quot;,
128-
&quot;kotlin-language-version-configured&quot;: &quot;true&quot;,
129-
&quot;last_opened_file_path&quot;: &quot;C:/Users/samsung-user/Documents/KU/clubs/KUIT/KUIT6_Server-webMVC&quot;,
130-
&quot;node.js.detected.package.eslint&quot;: &quot;true&quot;,
131-
&quot;node.js.detected.package.tslint&quot;: &quot;true&quot;,
132-
&quot;node.js.selected.package.eslint&quot;: &quot;(autodetect)&quot;,
133-
&quot;node.js.selected.package.tslint&quot;: &quot;(autodetect)&quot;,
134-
&quot;nodejs_package_manager_path&quot;: &quot;npm&quot;,
135-
&quot;project.structure.last.edited&quot;: &quot;Modules&quot;,
136-
&quot;project.structure.proportion&quot;: &quot;0.15&quot;,
137-
&quot;project.structure.side.proportion&quot;: &quot;0.23492062&quot;,
138-
&quot;settings.editor.selected.configurable&quot;: &quot;reference.settingsdialog.project.gradle&quot;,
139-
&quot;vue.rearranger.settings.migration&quot;: &quot;true&quot;
146+
<component name="PropertiesComponent"><![CDATA[{
147+
"keyToString": {
148+
"Application.WebServerLauncher.executor": "Run",
149+
"Gradle.KUIT6_Server-webMVC.executor": "Run",
150+
"JUnit.UserTest.executor": "Run",
151+
"RunOnceActivity.ShowReadmeOnStart": "true",
152+
"git-widget-placeholder": "week5junyong",
153+
"kotlin-language-version-configured": "true",
154+
"last_opened_file_path": "C:/Users/samsung-user/Documents/KU/clubs/KUIT/KUIT6_Server-webMVC",
155+
"node.js.detected.package.eslint": "true",
156+
"node.js.detected.package.tslint": "true",
157+
"node.js.selected.package.eslint": "(autodetect)",
158+
"node.js.selected.package.tslint": "(autodetect)",
159+
"nodejs_package_manager_path": "npm",
160+
"project.structure.last.edited": "Modules",
161+
"project.structure.proportion": "0.15",
162+
"project.structure.side.proportion": "0.23492062",
163+
"settings.editor.selected.configurable": "reference.settingsdialog.project.gradle",
164+
"vue.rearranger.settings.migration": "true"
140165
}
141-
}</component>
142-
<component name="RunManager" selected="Application.WebServerLauncher">
166+
}]]></component>
167+
<component name="RecentsManager">
168+
<key name="MoveFile.RECENT_KEYS">
169+
<recent name="C:\Users\samsung-user\Documents\KU\clubs\KUIT\KUIT6_Server-webMVC\src\main" />
170+
</key>
171+
</component>
172+
<component name="RunManager" selected="Gradle.KUIT6_Server-webMVC">
143173
<configuration default="true" type="Applet" factoryName="Applet">
144174
<module name="" />
145175
<option name="MAIN_CLASS_NAME" />
@@ -288,7 +318,8 @@
288318
<workItem from="1761730317572" duration="1356000" />
289319
<workItem from="1761813440661" duration="22235000" />
290320
<workItem from="1761983761744" duration="329000" />
291-
<workItem from="1762087694007" duration="8792000" />
321+
<workItem from="1762087694007" duration="8947000" />
322+
<workItem from="1762319002804" duration="6322000" />
292323
</task>
293324
<servers />
294325
</component>
Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,28 @@
11
import org.apache.catalina.startup.Tomcat;
2+
import org.springframework.boot.SpringApplication;
3+
import org.springframework.boot.autoconfigure.SpringBootApplication;
24

35

46
import java.io.File;
57
import java.util.logging.Logger;
68

9+
@SpringBootApplication
710
public class WebServerLauncher {
811
private static final Logger logger = Logger.getLogger(WebServerLauncher.class.getName());
912

1013
public static void main(String[] args) throws Exception {
11-
String webappDirLocation = "./webapp/";
12-
Tomcat tomcat = new Tomcat();
13-
tomcat.setPort(8080);
14-
tomcat.getConnector();
14+
SpringApplication.run(WebServerLauncher.class, args);
1515

16-
tomcat.addWebapp("", new File(webappDirLocation).getAbsolutePath());
17-
logger.info("configuring app with basedir: " + new File(webappDirLocation).getAbsolutePath());
1816

19-
tomcat.start();
20-
tomcat.getServer().await();
17+
// String webappDirLocation = "./webapp/";
18+
// Tomcat tomcat = new Tomcat();
19+
// tomcat.setPort(8080);
20+
// tomcat.getConnector();
21+
//
22+
// tomcat.addWebapp("", new File(webappDirLocation).getAbsolutePath());
23+
// logger.info("configuring app with basedir: " + new File(webappDirLocation).getAbsolutePath());
24+
//
25+
// tomcat.start();
26+
// tomcat.getServer().await();
2127
}
2228
}
Lines changed: 73 additions & 73 deletions
Original file line numberDiff line numberDiff line change
@@ -1,73 +1,73 @@
1-
package core.jdbc;
2-
3-
4-
import java.sql.Connection;
5-
import java.sql.PreparedStatement;
6-
import java.sql.ResultSet;
7-
import java.sql.SQLException;
8-
import java.sql.Statement;
9-
import java.util.ArrayList;
10-
import java.util.List;
11-
12-
public class JdbcTemplate<T> {
13-
14-
public void update(String sql, PreparedStatementSetter pstmtSetter) throws SQLException {
15-
try (Connection conn = ConnectionManager.getConnection();
16-
PreparedStatement pstmt = conn.prepareStatement(sql);) {
17-
18-
pstmtSetter.setParameters(pstmt);
19-
pstmt.executeUpdate();
20-
}
21-
}
22-
23-
public void update(String sql, PreparedStatementSetter pstmtSetter, KeyHolder holder) throws SQLException {
24-
try (Connection conn = ConnectionManager.getConnection();
25-
PreparedStatement pstmt = conn.prepareStatement(sql, Statement.RETURN_GENERATED_KEYS)) {
26-
27-
pstmtSetter.setParameters(pstmt);
28-
pstmt.executeUpdate();
29-
30-
if (holder != null) {
31-
try (ResultSet rs = pstmt.getGeneratedKeys()) {
32-
if (rs.next()) {
33-
holder.setId(rs.getLong(1));
34-
}
35-
}
36-
}
37-
}
38-
}
39-
40-
41-
public List<T> query(String sql, RowMapper<T> rowMapper) throws SQLException {
42-
List<T> objects = new ArrayList<>();
43-
44-
try (Connection conn = ConnectionManager.getConnection();
45-
PreparedStatement pstmt = conn.prepareStatement(sql);
46-
ResultSet rs = pstmt.executeQuery();) {
47-
48-
while (rs.next()) {
49-
T object = rowMapper.mapRow(rs);
50-
objects.add(object);
51-
}
52-
}
53-
return objects;
54-
}
55-
56-
public T queryForObject(String sql, PreparedStatementSetter pstmtSetter, RowMapper<T> rowMapper) throws SQLException {
57-
T object = null;
58-
59-
try(Connection conn = ConnectionManager.getConnection();
60-
PreparedStatement pstmt = conn.prepareStatement(sql);) {
61-
pstmtSetter.setParameters(pstmt);
62-
63-
try (ResultSet rs = pstmt.executeQuery()) {
64-
if (rs.next()) {
65-
object = rowMapper.mapRow(rs);
66-
}
67-
}
68-
}
69-
70-
return object;
71-
}
72-
73-
}
1+
//package core.jdbc;
2+
//
3+
//
4+
//import java.sql.Connection;
5+
//import java.sql.PreparedStatement;
6+
//import java.sql.ResultSet;
7+
//import java.sql.SQLException;
8+
//import java.sql.Statement;
9+
//import java.util.ArrayList;
10+
//import java.util.List;
11+
//
12+
//public class JdbcTemplate<T> {
13+
//
14+
// public void update(String sql, PreparedStatementSetter pstmtSetter) throws SQLException {
15+
// try (Connection conn = ConnectionManager.getConnection();
16+
// PreparedStatement pstmt = conn.prepareStatement(sql);) {
17+
//
18+
// pstmtSetter.setParameters(pstmt);
19+
// pstmt.executeUpdate();
20+
// }
21+
// }
22+
//
23+
// public void update(String sql, PreparedStatementSetter pstmtSetter, KeyHolder holder) throws SQLException {
24+
// try (Connection conn = ConnectionManager.getConnection();
25+
// PreparedStatement pstmt = conn.prepareStatement(sql, Statement.RETURN_GENERATED_KEYS)) {
26+
//
27+
// pstmtSetter.setParameters(pstmt);
28+
// pstmt.executeUpdate();
29+
//
30+
// if (holder != null) {
31+
// try (ResultSet rs = pstmt.getGeneratedKeys()) {
32+
// if (rs.next()) {
33+
// holder.setId(rs.getLong(1));
34+
// }
35+
// }
36+
// }
37+
// }
38+
// }
39+
//
40+
//
41+
// public List<T> query(String sql, RowMapper<T> rowMapper) throws SQLException {
42+
// List<T> objects = new ArrayList<>();
43+
//
44+
// try (Connection conn = ConnectionManager.getConnection();
45+
// PreparedStatement pstmt = conn.prepareStatement(sql);
46+
// ResultSet rs = pstmt.executeQuery();) {
47+
//
48+
// while (rs.next()) {
49+
// T object = rowMapper.mapRow(rs);
50+
// objects.add(object);
51+
// }
52+
// }
53+
// return objects;
54+
// }
55+
//
56+
// public T queryForObject(String sql, PreparedStatementSetter pstmtSetter, RowMapper<T> rowMapper) throws SQLException {
57+
// T object = null;
58+
//
59+
// try(Connection conn = ConnectionManager.getConnection();
60+
// PreparedStatement pstmt = conn.prepareStatement(sql);) {
61+
// pstmtSetter.setParameters(pstmt);
62+
//
63+
// try (ResultSet rs = pstmt.executeQuery()) {
64+
// if (rs.next()) {
65+
// object = rowMapper.mapRow(rs);
66+
// }
67+
// }
68+
// }
69+
//
70+
// return object;
71+
// }
72+
//
73+
//}

0 commit comments

Comments
 (0)