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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T02:19:34+00:00 2026-05-28T02:19:34+00:00

I have: Project \-src/main/resources \-src/main/java \-src/test/resources \-TestDataSourceContext.xml \-src/test/java and DatabaseUtils \-src/main/resources \-src/main/java \-src/test/resources \-AbstractTestDataSourceContext.xml

  • 0

I have:

Project
     \-src/main/resources
     \-src/main/java
     \-src/test/resources
                        \-TestDataSourceContext.xml
     \-src/test/java

and

DatabaseUtils
     \-src/main/resources
     \-src/main/java
     \-src/test/resources
                        \-AbstractTestDataSourceContext.xml
     \-src/test/java

In my Pom for Project I have a dependency as follows:
`

<dependencies>
    <dependency>
        <groupId>uk.co.domain.databaseutils</groupId>
        <artifactId>DatabaseUtils</artifactId>
        <version>${buildVersion}</version>
    </dependency> 
</dependencies>

Then in TestDataSourceContext.xml I have:

<import resource="classpath:AbstractTestDataSourceContext.xml"/>

Of course I get a filenotfoundexception when trying to do the import when running unit tests for Project, as AbstractTestDataSourceContext.xml is not included on the classpath. Is there a straightforward way of getting this file on the class path? Is there a maven option, a plugin etc? So when I depend on DatabaseUtils I can take all it’s resources, get DatabaseUtils to package it’s resource etc… I am still relatively new to Maven but it seems bizarre to me that this would be complicated to do.

  • 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-28T02:19:34+00:00Added an answer on May 28, 2026 at 2:19 am

    What you usually do, you include another dependency with scope test:

    <dependency>
        <groupId>uk.co.domain.databaseutils</groupId>
        <artifactId>DatabaseUtils</artifactId>
        <version>${buildVersion}</version>
        <scope>test</scope>
        <type>test-jar</type>
    </dependency> 
    

    It tells maven to include test-jar (should be called DatabaseUtils-<version>-tests.jar) on classpath for running tests (scope test).

    This assumes there is a proper DatabaseUtils test jar available which should be the case if it’s installed in a default way by maven.

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

Sidebar

Related Questions

I have a Maven project structured like this: src/main/java/test/App.java src/main/resources/config/message.txt Inside App.java, I have
I have a test project requiring some heavy jars which i put in ${M2_HOME}\test\src\main\resources\
I have a maven project with the following packages (for illustration only): Root: src/main/java
Most of our Eclipse projects have multiple source folders, for example: src/main/java src/test/java When
This is the directory structure of the project (maven2 is used): pom.xml /src /main
I have java class files and property files in the same directory. src/main/java/com/berlin/Test.class src/main/java/com/berlin/Test.properties
In my project, I have a resources directory ( src/main/resources ) that contains properties
here is the structure of my project. proj ---src ----main ----java ----Main.java ----resources ----res.txt
My need is to cretae a project whose structure is : Java_resources/src/main/java Java_resources/src/test/java and
Suppose I have the following directory layout in a Maven project: src/ |-- main

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.