Is it possible to use Vagrant with intelliJ?

2019-03-11 10:11发布

问题:

Let's say I'm working with Java and using IntelliJ to do things like build and deploy and other things like that.

I haven't used Vagrant before, but is it possible to keep using IntelliJ for the building and deployment while running a Vagrant instance?

回答1:

Yes, you can use your IDE with Vagrant. I just spent a lot of time thinking about how to do this and answering a similar question, hopefully this gives you some context.

Vagrant for a Java project: should you compile in the VM or on the host?

With the VM on a private network, you can deploy a WAR to a running web server as you would any remote server. Alternatively, from inside the VM you can symlink the webapps folder to the compile target on your host, eliminating the need to build a WAR and redeploy explicitly.



回答2:

You can also create a NFS shared directory in your vagrant and then you can access it both in your localhost and the vagrant box.

Just add this line to your Vagrantfile and then execute vagrant reload:

config.vm.synced_folder "shared", "/home/vagrant/shared", type: "nfs" ,  mount_options: ['rw', 'vers=3', 'tcp', 'fsc' ,'actimeo=2']

You can find the shared directory in the same folder as your Vagrantfile