Utilized ngrok to expose the local backend server via a public URL, making it accessible externally.
Added CORS settings on the backend server to allow requests from different domains.
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.CorsRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
@Configuration
public class WebConfig implements WebMvcConfigurer {
@Override
public void addCorsMappings(CorsRegistry registry) {
registry.addMapping("/**")
.allowedOrigins("http://localhost:3000") // 프론트엔드 주소
.allowedMethods("GET", "POST", "PUT", "DELETE")
.allowedHeaders("*")
.allowCredentials(true);
}
}
// =============== 초기 실행 함수 ================== //
// # 전체 ToDo 목록 렌더링
fetchAndRenderAllTodos();
// # 상대방과 공유 할 수 있도록, 2초마다 viewingsession 확인 후 렌더링
setInterval((e) => {
renderViewingSession()
}, 2000);Error Code
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'todoRepository' defined in file [todoRepository 저장 경로]: Cannot resolve reference to bean 'sqlSessionTemplate' while setting bean property 'sqlSessionTemplate'
Cause
Wrong type-aliases-package setting
MyBatis을 이용한 JDBC 구현 중, @Mapper 클래스인 TodoRepository와 매핑되는 매퍼 파일(xml)에 resultTyle을 아래와 같이 입력하였는데,
-- resultType에 클래스 이름만 적으려면,
-- application.yml 파일의 mybatis:type-aliases-package에 파일 경로를 적어줘야 함
<select id="findTodos" resultType="Todo">
그런데 application.xml 파일에 type-aliases-package 경로를 잘못 지정해 두었음

<li class="task">
<label for="\${todo.id}">
<input type="checkbox" id="\${todo.id}" \${todo.completed ? 'checked' : ''}>
<p class="\${todo.isCompleted ? 'completed' : 'pending'}">\${todo.task}</p>
</label>
<div class="settings">
<i class="uil uil-ellipsis-h"></i>
<ul class="task-menu">
<li>
<i class="uil uil-pen"></i>Edit
</li>
</ul>
</div>
</li>