英文:
Deploy frontend in angular and backend in java in cpanel
问题
我已使用Angular框架进行前端开发,并创建了Spring Boot应用程序作为后端。要在本地服务器(我的计算机)上运行我的应用程序,首先在Eclipse中运行Spring Boot应用程序,然后通过Angular CLI运行Angular应用程序。但是如何将我的项目部署和托管到cPanel上呢?
英文:
I have used angular framework for frontend development and created spring boot application for backend. To run my application on my local server(my computer), I first run spring boot application in eclipse and angular application through angular cli. But how can I deploy and host my project to cpanel?
答案1
得分: 1
Step 1) Angular构建命令 - "ng build --prod"。这将在您的Angular项目主目录中创建一个dist文件夹,如果您导航到此目录,您将看到文件夹,其中将可用assets、index.html、main.xxxxxxxx.js、polyfills.xxxxxxxx.js和runtime.xxxxxxxxx.js等。
Angular dist文件夹(miracleApp是我的应用程序名称,因此所有文件都将在此文件夹中)
Step 2) 从dist目录中复制所有上述文件,并粘贴到您Java项目的src/main/resources目录中。
Step 3) 现在执行Maven构建(希望您的项目是Maven项目),使用"package"作为目标,如果构建成功,您将看到一个target文件夹,其中将有一个jar或war(取决于您在pom.xml中选择的打包选项)文件,其中将包含您的Angular和Java代码,并且可以立即使用。
Step 4) 现在转到您的服务提供商控制面板(确保您的服务提供商接受Java应用程序部署,而不仅仅是PHP,我曾经遇到过这样的问题,有些服务提供商只允许PHP应用程序),并使用此打包的jar或war文件部署到提供的服务器上。
英文:
Step 1) Angular build command - "ng build --prod" . This will create a dist folder in you angular project main directory, if you navigate in to this directory you will see folders where assets, index.html, main.xxxxxxxx.js, polyfills.xxxxxxxx.js and runtime.xxxxxxxxx.js etc will be available
Angular dist folder (miracleApp is my app name, so all files will be under this)
Step 2) Copy all the above files from the dist directory and paste them in src/main/resources directory of your java project
Step 3) Now do a maven build (hope yours is a maven project) using "package" as the goal and if build is successful you will see a target folder with either a jar or a war (depending on what you choose packaging option in pom.xml) file which will have all your angular and java code and ready to use
Step 4) Now go to your service providers cpanel (make sure your service provider accepts java application deployments and not just php, I faced this issue sometime back where service providers allow only php applications) and use this packaged jar or war file for deployment on the provided server
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论