如何为Java Web应用程序创建开发服务器

huangapple go评论83阅读模式
英文:

How to create a development server for a java web application

问题

我们想要为我们的学校项目构建一个Java Web应用程序(servlet和JSP),并与多名开发人员合作,我想优化开发工作流,有几个原因:

  1. 这样我们就可以使用相同的工具和相同的版本(SDK,tomcat服务器,MySQL数据库)进行工作。

  2. 防止出现已知的“在我的机器上可以运行”的情况。

  3. 快速设置开发人员并使其运行起来,无需在主机上安装软件。

  4. 学习目的。

所以,我想要做的是设置一个虚拟机,并使用Vagrant进行配置,以安装适当的SDK,Tomcat服务器和MySQL客户端-服务器,甚至可能在Vagrant虚拟机内部设置一个docker-compose文件?这是一个好主意吗?

我们不受任何集成开发环境(IDE)的限制,我找到了一些有用的Vagrant虚拟机,可以帮助我们:

https://github.com/ssledz/vagrant-boxes/tree/master/java-dev-environment
https://github.com/timofurrer/java-dev

我可以配置IDE,在虚拟机启动时使用正在运行的Tomcat服务器吗,而无需在IDE上手动配置它?

这是否过于繁琐?我们应该创建一个更简单的开发服务器吗?如果是这样,应该如何操作?

现在你可能已经猜到,我们对Java Web应用程序开发或团队合作没有太多经验,但这是一个很好的学习机会,所以请随时提出不同的方法,主要目标是获得一个我们都可以使用的开发工作区,并遵循最佳实践和行业标准。

我们该如何实现这一目标?

英文:

We want to build a java web application (servlets and JSP) with multiple developers for our school project, and I want to optimize the development workflow for a couple of reasons:

  1. So we can all work with the same tools and with the same versions (SDK, tomcat-server, MySQL database)

  2. prevent the known "but it works on my machine" statement.

  3. Set developers up and running quickly , no need to install software on the host machine.

  4. Learning purposes.

So what I was thinking to do is to set up a VM and configure it using vagrant to install the proper SDK, tomcat server, and MySQL client-server, maybe even set up a docker-compose file inside the vagrant machine? is that a good idea?

We are not bound to any IDE, and I found some useful vagrant boxes that can help:

https://github.com/ssledz/vagrant-boxes/tree/master/java-dev-environment
https://github.com/timofurrer/java-dev

Can I configure the IDE to use my running tomcat-server when the machine is booting, without the need to configure it manually on the IDE?

Is that an overkill? should we create a simpler development server? if so, how?

Now as you may have guessed we don't have a lot of experience with Java web application development or working as a team, but it's a good opportunity to learn, so feel free to suggest a different approach, the main goal here is to get a development workspace we could all use, and following best practices and industry standards.

How could we achieve that?

答案1

得分: 0

> 所以我考虑做的是设置一个虚拟机,并使用 Vagrant 配置它,安装适当的 SDK、Tomcat 服务器和 MySQL 客户端,甚至在 Vagrant 虚拟机内部设置一个 Docker Compose 文件?这是个好主意。

当然,这是一个好主意。Docker 之所以如此受欢迎,原因也在于此。

>
> 使用 Eclipse 会更容易吗?

IntelliJ IDEEclipse 一样都很好且受欢迎。它们之间有一些不同的功能。因此,选择使用哪个集成开发环境应该取决于你对该 IDE 的经验。

> 我们应该如何将应用部署到运行在虚拟机上的 Tomcat 服务器?还需要在主机机器上再部署另一个服务器吗?

我建议您使用 Jenkins 构建持续集成/持续交付(CI/CD)流水线。此外,务必使用一些源代码管理软件(我推荐使用 Git)。

英文:

> So what I was thinking to do is to set up a VM and configure it using
> vagrant to install the proper SDK, tomcat server, and MySQL
> client-server, maybe even set up a docker-compose file inside the
> vagrant machine? is that a good idea?

Of course, it is a good idea. Docker became so popular for the same reason.

>
> will it be easier working with eclipse?

IntelliJ IDE and eclipse are equally good and popular. Both of them have some features different from each other. So, the choice of and IDE should depend on your experience with the IDE.

> How should we deploy the app to the tomcat server running on the
> virtual machine? with another server on the host machine?

I suggest you build a CI/CD pipeline using Jenkins. Also, do use some source control software (I recommend git).

答案2

得分: 0

好的,我所做的是在现有的 Vagrant Java 开发环境中进行构建,该环境已经包含了 Java 和 Eclipse。我添加了一个安装 Tomcat 7 服务器以及一个带有一些模拟数据的 MySQL 数据库的脚本。

这是链接:https://github.com/nati-elmaliach/vagrant-java-development-server

英文:

Ok, so What I did was to build on an existing vagrant java-dev box that comes with java and eclipse, and I added a script to install tomcat server 7, and a MySQL database with some mock data.

Here is a link: https://github.com/nati-elmaliach/vagrant-java-development-server

huangapple
  • 本文由 发表于 2020年4月5日 18:43:19
  • 转载请务必保留本文链接:https://go.coder-hub.com/61041327.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定