Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6628849
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T22:10:35+00:00 2026-05-25T22:10:35+00:00

Currently I have 1 Guice module in my project which defines all bindings. Now

  • 0

Currently I have 1 Guice module in my project which defines all bindings.
Now I want to write integration tests and I need to bind the dependencies of a specific class. If I use the existing module, Guice will bind all dependencies. But I think this in not correct for integration tests.

So, do I need a module for every class that only the necessary dependencies will be bind?

Thanks.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T22:10:35+00:00Added an answer on May 25, 2026 at 10:10 pm

    Creating one Guice module to bind all bindings in a project isn’t optimal, but neither is creating one module per binding.

    In general, you simply want to “group related bindings into a module”. Doing so is somewhat of an art, rather than a science, so I can’t give perfect advice.

    If your project has a solid Java package structure, then creating one Guice module per package is a good place to start (though, if your packages contain lots of classes, you may even want several per package). Using per-package Guice modules also gives you the advantage of letting you make your implementation classes be package-private (which is good for encapsulation!).

    One specific example: if your project has external dependencies, it’s probably good to bind them separately from your application code. For example, if you have a webserver that talks to an RPC service on another server, it’s good to bind the service separately from the code that talks to the service (that way, you can mock out the external service without mocking any application code).

    As a crutch, you can also use Modules.override(...)[1], but doing so is generally a sign that your modules are too big.

    1. http://google-guice.googlecode.com/svn/trunk/javadoc/com/google/inject/util/Modules.html
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I currently have a functioning in-house Windows Forms application which extensively uses the DataGridView
I currently have a number of web applications which access a common service running
Has anybody ever seen/attempted to write a service locator pattern which uses a Guice
I currently have an ASP.NET script for a TV guide which displays the data
I've been learning some Clojure, and I currently have a single .clj file which
Currently I have the below jQuery which uses the colorbox plugin http://colorpowered.com/colorbox/ $(document).ready(function(){ $(.altbgcolor).hover(function()
I have started using Guice to do some dependency injection on a project, primarily
Currently I have a dedicated server with WHM and Joomla running. I want to
I want to implement semantic search into my rails site. I currently have a
I currently have an MS Access application that connects to a PostgreSQL database via

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.