* Eclipse Spring 프로젝트 생성 및 초기 개발환경 구축하는 방법 참고
| 항목 | 내용 |
|---|---|
| Language | Java 11 |
| Backend IDE | Eclipse 2023-12 |
| Spring | 5.3.36 |
| Tomcat | 9.0.105 |
| DataBase | MySQL 8.0.33 (MyBatis 3.5.15) |
| Build Tool | Maven 3.8.x (설정파일 : pom.xml) |
| Frontend IDE | VSCode |
| Vue.js | 3.16.4 |
* 백엔드 전체 코드 :
https://velog.io/@ryuneng2/Spring-스프링-프로젝트-간단-DB-조회-로직-백엔드-ver
package com.calendarapp.controller;
import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.calendarapp.service.ScheduleService;
import com.calendarapp.vo.Schedule;
@RestController
@CrossOrigin(origins = "http://localhost:5173") // 추가
@RequestMapping("/api/schedules")
public class ScheduleController {
@Autowired
private ScheduleService scheduleService;
@GetMapping
public List<Schedule> getSchedules() {
return scheduleService.getSchedules();
}
}
node -vnpm -vcd [디렉토리]npm init vue@latestcd [디렉토리]npm installnpm run dev⚠️ 오류

💡 해결 방법
Get-ExecutionPolicy 명령어 입력 (현재 정책 확인)Set-ExecutionPolicy RemoteSigned -Scope CurrentUser 명령어 입력Y 또는 예를 입력


npm install 명령어 입력npm install axios 명령어 입력
npm install vue-router@4 명령어 입력
<template>
<div id="app">
<h1>일정 관리 프로그램</h1>
<nav>
<router-link to="/list">일정 목록</router-link>
</nav>
<router-view /> <!-- 라우팅되는 컴포넌트가 표시되는 영역 -->
</div>
</template>
import { createRouter, createWebHistory } from 'vue-router';
import ScheduleList from '../components/ScheduleList.vue';
const routes = [
{ path: '/list', component: ScheduleList }
];
const router = createRouter({
history: createWebHistory(),
routes
});
export default router;
<template>
<div>
<h2>일정 목록</h2>
<ul>
<li v-for="schedule in schedules" :key="schedule.id">
{{ schedule.id }}. {{ schedule.title }}
</li>
</ul>
</div>
</template>
<script>
import axios from 'axios';
export default {
name: 'ScheduleList',
data() {
return {
schedules: []
};
},
mounted() {
axios.get('http://localhost:8080/api/schedules') // Spring 서버 포트
.then(response => {
this.schedules = response.data;
})
.catch(error => {
console.error('일정 조회 실패:', error);
});
}
};
</script>
import { createApp } from 'vue';
import App from './App.vue';
import router from './router';
const app = createApp(App);
app.use(router);
app.mount('#app');
<!DOCTYPE html>
<html lang="ko">
<head>
<meta charset="UTF-8">
<title>Vue Calendar App</title>
</head>
<body>
<div id="app"></div>
<script type="module" src="/src/main.js"></script>
</body>
</html>
1. 터미널 > Frontend 최상위 디렉토리 경로 진입
2. npm run dev 명령어 입력

3. 브라우저 접속


DB에 저장된 일정 목록이 성공적으로 조회되는 것을 확인할 수 있다 !