Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I found my answer. The problem with my unit test is that I was using:</p> <pre><code> @ContextConfiguration(locations = {"classpath*:project-infrastructure.xml","classpath*:applicationContext.xml"}) </code></pre> <p>which means this was pulling in the completely wrong applicationContext.xml file, and the wrong project-infrastructure.xml file. </p> <p>In my Spring DAO app, I made sure I was using an app context file specifically to this project, so I renamed it a unique name: myproject1-app-context.xml and myproject1-infrastructure.xml file.</p> <p>In this maven project, the directory structure looks like:</p> <p>src/main/java src/main/resources src/main/resources/spring &lt;-- where my spring app context files are located</p> <p>In the unit test I changed the location to:</p> <pre><code>@ContextConfiguration(locations = {"classpath:/spring/myproject1-infrastructure.xml", "classpath:/spring/myproject1-app-context.xml"}) </code></pre> <p>And once I did that, I stopped getting the autowired error. </p> <p>I know there is some code or trick to point out the files in my classpath that are being used. I should use that someday, but at least this solved my problem.</p> <p>As was previously stated, using @Repository in the DAO class, and removing the definition from the myproject1-app-context.xml file, and I did include:</p> <pre><code> &lt;!-- Activates scanning of @Autowired --&gt; &lt;context:annotation-config /&gt; &lt;!-- Activates scanning of @Repository and @Service --&gt; &lt;context:component-scan base-package="com.tom.project" /&gt; </code></pre> <p>This was included in the myproject1-app-context.xml file. </p> <p>So, I hope this helps someone out sometime ....</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload