vue와 spring 통합하기

이태규·2022년 4월 12일
0

spring

목록 보기
54/64

1. 홈컨트롤러 만들기

// 127.0.0.1:9090/ROOT/vue
    @GetMapping(value = "/vue")
    public String vueGet() {
        // vue에서 build한 index.html파일의 위치
        return "/vue/index";
    }

2. build하고 파일집어넣기

dist안에

css, img, js, favicon.ico는 static안
index.html은 template, vue안에

주의할 점

/ROOT가 빠져서 안나옴

http://127.0.0.1:9090/ROOT/css/app.fb0c6e1c.css가 되었어야 함.

3. vue.config 설정 다시하기

module.exports = {
    // 개발 서버 설정
    devServer: {
        // 프록시 설정
        proxy: {
            // 프록시 요청을 보낼 api의 시작 부분
            '/ROOT': {
                // 프록시 요청을 보낼 서버의 주소
                target: 'http://localhost:9090',
                changeOrigin: true,
                logLevel: 'debug',
            }
        },
       
    },

    // 리소스의 위치
    publicPath : '/ROOT/vue/'
};

다시 빌드 시켜준다.

npm run build
profile
한 걸음씩 나아가자

0개의 댓글