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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T22:20:09+00:00 2026-06-02T22:20:09+00:00

First of all I’m quite new to Springframwork. Let’s say I have a controller

  • 0

First of all I’m quite new to Springframwork.

Let’s say I have a controller in Spring-MVC:

@Controller
public class FooController {

    @Autowired
    private Foo foo;

    @Autowired
    private FooService fooService;

    @RequestMapping(value="/addfoo", method = RequestMethod.GET)
    public void addRequest(          
        @RequestParam(value="rq_param", required=true) String param){

        foo.setValue(param);    
        fooService.addFoo(foo);                     
    }
}

I need to add Foo into a database. But before I need to set a value. This should happen when a certain request comes in (from elsewhere).

Here’s my Service:

@Service
public class FooServiceImpl implements FooService {

    @Autowired
    private FooDAO fooDAO;

    @Transactional
    public void addFoo(Foo foo) {
        fooDAO.addFoo(foo);
    }
}

But this doesn’t work. I get

org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'fooController': Injection of autowired dependencies failed;

I’m quite sure that I’ve a made a basic mistake due to my lack of knowledge about IoC…

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-06-02T22:20:12+00:00Added an answer on June 2, 2026 at 10:20 pm

    I don’t think you should inject the Foo. It looks like a model object to me, not an interface-based service or controller.

    You should create one using new when the request comes in, outside of Spring’s control. You want to bind the value from the request parameter into the new Foo object and persist it.

    Every object in a Spring project need not be under the control of the bean factory.

    Usually you see calls to new for objects within method scope. They’re usually POJO model objects that don’t have interfaces. Your cases seems to be one of them to me.

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

Sidebar

Related Questions

First of all, I'm quite new to the Android and JAVA world (coming from
First of all, let me say that I am not a professional coder -
First of all, let me clarify that I know you cannot have actual abstract
First of all Im new to vb 2010 and so far have enjoyed what
First of all, regular expressions are quite possibly the most confusing thing I have
first of all i would like to say i know its probably an easy
First of all, apologize because I have seen some posts about this, but I
First of all i have to those categoryIDs 1-whos parentcategoryID only appears one 2-ParentCategoryID
First of all - I don't have a problem with bad-indentated code and I
I have 3 cards. at first all cards move to the right, then after

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.