Java, multiple cans or one big?

In terms of efficiency and memory usage, would it be better to set up a large jar with classes / packages for each function as needed? Or better yet, divide it into smaller, more manageable cans?

Suppose I have a large project with 20-30 unrelated software packages:

com.example.test
   - class 1
   - class 2
   - class 3
   - another.package
      - class 1
      - class 2
      - class 3
   - another.package
      - class 1
      - class 2
      - class 3
   - another.package
      - class 1
      - class 2
      - class 3

Would it be more effective to split each package into its own cans? And have multiple smaller, lighter cans? I'm not sure if this is important, but I'm curious because if I separate everything a little, it will make further development easier (as long as there is no performance disadvantage)

Solution

If the bags are not related, they should not be in the same jar

By splitting jars, users can choose which packages are needed in the deployment, and only those packages are included

You want to deploy as little code as possible Anything extra is an extra potential problem, bug, security vulnerability Unnecessary things can also slow down class loaders, although this is a minor problem compared to others I mentioned earlier

If some or all of them are used together, they can be bundled together for practical reasons

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>