简体   繁体   中英

Integrate Angular4 as front-end and Java as back-end

I'm following this instruction: http://javasampleapproach.com/java-integration/integrate-angular-4-springboot-web-app-springtoolsuite to create angular4 as front-end and java as back-end. I have successfully in integrate it. But I'm facing a problem is: Since the angular and Java in two different projects, each time I change in front-end, I need to run ng build --env=prod to make the dist folder, then copy the all in dist folder to resource/static in back-end. Please tell me if we have any way to make if I change in angular project I don't need to init the dist folder and copy and paste it to java project.

Thanks so much.

its simple...you have to make a parent maven project and two subprojects like frontend and backend...you can use frontend-maven-plugin for automating node builds and ng build and you can pack this as a frontend.jar and have this as a dependency in you backend sub project...there is a useful link which discuss more on this project... check out this link

Why you cannot just run your client with http://localhost:4200 ?

As I can see you have already the settings for proxy: redirect all requests with prefix /api to the server http://localhost:8080 :

proxy.conf.json

{
    "/api": {
        "target": "http://localhost:8080",
        "secure": false
    }
}

That mean you can run server on port 8080 and the client on port 4200 (client will redirect all request to server) and you should not copy your client to server folder.

您可以使用Java angular-cli.json路径更改angular-cli.json文件中的outdir字段

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM