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 8274015
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T07:37:16+00:00 2026-06-08T07:37:16+00:00

I am not sure if I am allowed to ask more than one question

  • 0

I am not sure if I am allowed to ask more than one question in a post, but here it is,

For example I have the following,

Controllers

@Controller
public class FooController{

    @Autowired
    private FooService fooService;

    @RequestMapping(value="/foo", method=RequestMethod.POST)
    public @ResponseBody foo(@RequestBody FooRequest request){
    }

}
@Controller
public class BarController{

    @Autowired
    private FooService fooService;

    @RequestMapping(value="/bar", method=RequestMethod.POST)
    public @ResponseBody bar(@RequestBody FooRequest request){
    }

}

Service

public class FooService{

    private Foo foo;

    public Foo getFoo() {
        return foo;
    }
    public void setFoo(Foo foo) {
        this.foo = foo;
    }
    public String doFoo(String str){
        return foo.doFoo(str);
    }
}

class to do the job

public class Foo{

    public String doFoo(String str){
        return (str + " is foo");
    }
}

create beans using dependency injection

<context:annotation-config/>

<bean id="fooService" class="com.myapp.service.FooService">
    <property name="foo" ref="foo"></property>
</bean> 
<bean id="foo" class="com.myapp.foo.Foo">
</bean>

My questions are:

  1. I did not use @service annotation at class FooService, should I use it, and why?
  2. Is this configuration thread-safe or not, and why (how is it achieved if it is thread-safe)?
  3. Where can I find a tutorial about the layers (dao layers, service layer …) used in Spring design and the purpose of such a design?
  • 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-06-08T07:37:17+00:00Added an answer on June 8, 2026 at 7:37 am
    1. Using it would simply avoid the need for declaring the bean using XML. You chose to use annotations for your other beans. I would thus also use annotations for this one.
    2. Yes, it is, because Spring makes sure everything is properly wired up and initialized, with a synchronization barrier, before serving any request
    3. This is a very broad question. Layering is useful for separation of concerns, testability, ability to demarcate transactions declaratively, etc.
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

just a query more than anything. Not sure if im allowed to just ask
I am not sure if this general question is even allowed in here but
Not sure how to ask this, but i'll give it a try: I have
I'm not really sure if the questions that ask for opinion are allowed here,
Im not sure this is actually allowed here, but since I usually go to
I'm not sure if this is allowed but I have a main form that
Not sure how to frame this one, so here goes... I have a need
Not sure if im just being stupid or something but here goes i work
not sure what I'm missing here, but i keep getting the error. SQLSTATE[HY093]: Invalid
Not sure if this is the correct Stack Exchange website but here goes.. A

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.