简体   繁体   English

使用Java和Vue创建Web应用程序的更好方法

[英]Better way to create a web application with Java and Vue

I'm starting to get into web development a little more. 我开始进入Web开发了一点点。 Currently I use the Spark Framework along with Vue for the few apps I've made. 目前,我将Spark框架与Vue一起用于我制作的少数应用程序。 While this certainly works it's not ideal. 虽然这肯定有效,但并不理想。

The project is built with Maven (and NPM for Vue) and the build process looks something like this. 该项目是使用Maven(和NPM for Vue)构建的,构建过程看起来像这样。

  1. Maven packages the Spark Framework Java application Maven打包了Spark Framework Java应用程序
  2. Maven (with the frontend-maven-plugin) downloads node/npm and builds the Vue frontend Maven(使用frontend-maven-plugin)下载node / npm并构建Vue前端
  3. Maven copies the compiled resources into the jar as static assets Maven将编译后的资源作为静态资产复制到jar中

So the filesystem looks something like this 所以文件系统看起来像这样

/src/main/java (Spark Framework) / src / main / java(Spark框架)

/src/main/resources (Vue) / src / main / resources(Vue)

This leads to a couple of annoyances. 这会导致一些烦恼。

  1. Everything is in one repository. 一切都在一个存储库中。 Ideally I'd be able to have a separate repo for each layer of the project (One for Java, one for Vue) 理想情况下,我可以为项目的每一层都有一个单独的仓库(一个用于Java,一个用于Vue)
  2. Development workflow isn't ideal. 开发工作流程并不理想。 If I just want to test the Java part of the app, I still spend time compiling the frontend (Vue) 如果我只想测试应用程序的Java部分,我仍然花时间编译前端(Vue)
  3. A minor issue, but while working in an IDE, I'm dealing with deeply nested folders. 一个小问题,但在IDE中工作时,我正在处理深层嵌套的文件夹。 Anytime I want to edit the frontend, my folder structure looks something like /src/main/resources/project-vue/ 任何时候我想编辑前端,我的文件夹结构看起来像/ src / main / resources / project-vue /

Here's one of my projects that uses this model 这是我使用此模型的一个项目

So my question is: What's a better way to structure my application? 所以我的问题是: 构建我的应用程序的更好方法什么?

I've had a few months to think and in that time I've created a few more applications with Vue, here's the workflow I've started to take. 我有几个月的时间来思考,在那段时间我用Vue创建了一些应用程序,这是我开始采用的工作流程。

I create a GitHub organization for any project that has more than one layer. 我为任何具有多个图层的项目创建了一个GitHub组织。 For example, many of my projects have a REST API written in Java or JavaScript, and a web interface with Vue. 例如,我的许多项目都有一个用Java或JavaScript编写的REST API,以及一个带Vue的Web界面。 This organization will contain a repository for each layer. 该组织将包含每个层的存储库。 Here's a link to an organization that follows this idea. 这是一个遵循这个想法的组织的链接

This allows me to separate my backend and frontend, but it complicated deployment. 这允许我分离我的后端和前端,但它复杂的部署。 I can no longer serve my Vue files with the same web server as the API, but upon further thought that's probably a good thing. 我不能再使用与API相同的Web服务器来提供我的Vue文件,但进一步认为这可能是一件好事。

With this pattern I can host my static Vue site on Amazon S3 which is extremely cheap, and use free dynos with Heroku to host my API. 使用这种模式,我可以在Amazon S3上托管我的静态Vue站点,这非常便宜,并使用Heroku的免费dynos来托管我的API。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 在Java中创建字符串的更好方法 - better way to create a string in java 在Java Servlet和普通Java应用程序之间进行通信的更好方法 - Better way to communicate between Java Servlet and a normal Java Application Web Application和Desktop之间的通信有哪些更好的方法? - Communication between Web Application and Desktop, what better way? 什么是更好的Java Web应用程序框架(请提供建议)? - What are better Java web application frameworks (Suggestions please)? Java-过早的EOF-编写Web阅读器的更好方法? - Java - Premature EOF - Better Way to write web reader? 从Java应用程序加载自定义DSL配置的更好方法 - Better way to load custom DSL config from Java application 用Java Web Start程序创建客户机/服务器应用程序的最佳方法是什么? - What is the best way to create a client-server application with a Java Web Start program? 有没有比使用instanceof有条件地创建类型更好/更清晰的方法? 【JAVA] - Is there a better/cleaner way to conditionally create a type than using instanceof? [Java] 从Java中的priorityQueue创建有序数组的更好方法 - Better way to create an ordered array from priorityQueue in Java 我应该尝试在Java中创建可逆枚举还是有更好的方法? - Should I be trying to create a reversible enum in Java or is there a better way?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM