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

  • Home
  • SEARCH
  • 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 6663637
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T02:31:16+00:00 2026-05-26T02:31:16+00:00

Suppose we have a Class A, and B. inside B’s constructor, not only A

  • 0

Suppose we have a Class A, and B. inside B’s constructor, not only A is needed, but also some other String / boolean values. e.g

@Componenet(value = "B")
@DependsOn(value = "A")
public class B{
    ...
}
public B(A a_instance, String name1, String name2, boolean b1){
    ...
}

I know using annotation. but not knowing exactly, what should be done with those String/boolean values?

  • 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-26T02:31:16+00:00Added an answer on May 26, 2026 at 2:31 am

    Your question isn’t entirely clear. Your B constructor appears to be outside of class B. Aside from that, assuming there are no other constructors, what you have won’t work because Spring will look for a default constructor. I think what you’re asking is what to do if you want to @Autowired that constructor to get String and boolean values in it. If so, you want something like this:

    @Component
    public class B {
        @Autowired
        public B(A a,
                 @Value("${some.property.1}") String name1,
                 @Value("${some.property.2}") String name2,
                 @Value("${some.property.3}") boolean b1) {
            ...
        }
    }
    

    In this situation, @Value acts somewhat like @Qualifier would if you had multiple beans of type A.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Suppose you have some method that could be made static, inside a non-static class.
Suppose I have a class with some attributes. How is it best (in the
Suppose I have a class public class MyClass { private Set<String> set = new
Suppose I have some class which has a property actor_ of type Actor .
Suppose I have a class that processes some data: class SomeClass { public: void
Suppose I have this model: public class ViewModel { [Required] public string UserInput {
Suppose I have some code like this: class Visitor { public: Visitor(callBackFunction) {} void
I have a confusion on some piece of code. Inside a class I have
lets suppose you have 3 QRadioButtons instances inside a class self.Option1 = QRadioButton() self.Option2
Suppose I have a class, and I want to reference some elements in the

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.