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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T04:22:51+00:00 2026-05-27T04:22:51+00:00

I have a project that consists of various modules. Basically, I’ve worked with Spring

  • 0

I have a project that consists of various modules.
Basically, I’ve worked with Spring MVC & JUnit 4, and everything was working good.
But Now, I added few classes which aren’t related to testing or MVC, and the @Autowired annotation doesn’t inject objects to them.
The same objects are injected to the MVC and JUnit classes, so I realy confused.

This is the Spring Context XML:

<beans xmlns="http://www.springframework.org/schema/beans"
    xmlns:context="http://www.springframework.org/schema/context"
    xmlns:mvc="http://www.springframework.org/schema/mvc" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="
        http://www.springframework.org/schema/beans     
        http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
        http://www.springframework.org/schema/context 
        http://www.springframework.org/schema/context/spring-context-3.0.xsd
        http://www.springframework.org/schema/mvc
        http://www.springframework.org/schema/mvc/spring-mvc-3.0.xsd">

    <context:component-scan base-package="com.justic.more" />
    <mvc:annotation-driven />
    <context:annotation-config />
    <bean id="monkDAO" class="com.justic.more.data.monkDAO" />
    <bean id="BidDAO" class="com.justic.more.data.BidDAO" />

</beans>

The Class that I want to inject to:

@Component
Public Class Tesser {

@Autowired
MonkDAO monkdao;

...
blablabla
...
}
  • 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-27T04:22:53+00:00Added an answer on May 27, 2026 at 4:22 am

    From the chat with OP it became clear that he created the object like Tesser tesser = new Tesser() instead of injecting it into the test class.
    Spring has no chance to autowire dependencies in beans that it does not create itself.

    The solution is to autowire the Tesser object into the test class so Spring can inject the dependencies.

    @Autowired
    private Tesser tesser;
    
    @Test
    public void testSth() {
        assertTrue(tesser.someBoolReturningMethodUtilizingMonkDAO());
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am currently working on a project that consists of an ASP.NET MVC 2.0
I have an ASP.NET MVC 2 project that I'm working on and I'm wondering
I have a project that consists of a bunch of dynamically loaded modules. Originally,
I have maven project that consists of several modules. I want to add an
I have a Maven project that consists of several modules. I have a single
I have project that I'm working on that is going to require a webserver.
I have a project that I'm currently working on but it currently only supports
I have a project that I'm working on and I need to be able
I have a project that simply consists of files. I want to package those
I have a project that consists of a C# application that calls into 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.