开发者

Java - Difference between dist and deploy folders

开发者 https://www.devze.com 2023-04-05 16:06 出处:网络
Forgive me for a novice question, but what is the difference between the dist and deploy folders? It seems like t开发者_StackOverflow中文版he same thing - both contains the .jar of the files.However,

Forgive me for a novice question, but what is the difference between the dist and deploy folders? It seems like t开发者_StackOverflow中文版he same thing - both contains the .jar of the files. However, when you clean and build the project, it looks like only the dist folder is updated. How does the deploy folder get updated?

Thanks.


I will assume that you are using a directory layout similar to what Netbeans IDE creates by default.

  • dist is the folder where your generated archives are stored (so it gets updated through clean and build).
  • build folder contains compiled classes and resources, but not the compressed archives.

Maven, by default, places the content of both into a target folder.

A deploy folder is the place where you put your generated artifacts (either archives or directory trees with the same layout as archives, a.k.a. exploded archives) so that you Application Server can serve it.

In development environments it is not unusual to configure the server to scan the dist folders for generated artifacts and redeploy them. So, in that sense, deploy and dist folders can be the same.

You can even have "in place" deployment scenarios. This works by compiling your classes direct to WEB-INF/classes folder inside webapp (with something like Maven war:inplace goal). If you set your server to scan changes in this folder, you can edit resources such as jps in place and have it immediately reflected into your running application (a.k.a. exploded artifact hot deployment).

Of course that you can accomplish something similar by instructing your IDE to copy resources and compiled classes to a exploded archive structure and configuring your server to scan it. Netbeans tends to use build/web for that purpose.

Also sometimes incremental redeployment is not possible and frequently full redeploys are not desirable (some applications may take several minutes to redeploy). That is why you can use separate folders / deploy your artifacts as jars / wars / ears, etc.

Compiling, packaging and deploying are very different phases / concepts of a Build lifecycle, which may or may not happen together.

I hope this is enough info to get you going.

Cheers,


Typically a project is responsible for creating one artifact, when that artifact gets built it is put in a directory called target or dist. When your project is responsible for creating a web application, you need a place to layout the files in your project to run under your servlet container or app server, and that place is the deploy folder. So the dist directory would typically have a single artifact like a war, ear or jar, while the deploy folder would have the contents exploded in a directory structure where the app server can use them. How the deploy folder contents get updated depends on your build process or IDE integration.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号