Hi,
you have a few options based on your concrete scenario:
If you just want to unit test a ejb project you can create two
'persistence.xml' files one in 'src/main/resources' for production use
and one in 'src/test/resources' for testing. The testing persistence.xml
should then shadow the production one.
An other option would be to enable filtering on the resource dir:
<build>
<resources>
<resource>
<directory>src/main/resources</directory>
<filtering>true</filtering>
</resource>
</resources>
</build>
and have profiles for the different environments:
<profiles>
<profile>
<id>test</id>
<activation>
<activeByDefault>true</activeByDefault/>
</activation>
<properties>
<connection>testconnection</nconnection>
</properties>
</profile>
<profile>
<id>production</id>
<properties>
<connection>prodconnection</nconnection>
</properties>
</profile>
</profiles>
And put ${connection} in the persistence.xml.
Hope this helps
-Tim
Ryan Moquin schrieb:
Hi, I know that in order to use different configuration files (such as a
persistence.xml), such as test configurations vs. production configurations
I need to setup profiles to allow these different files to be used.
What is
the preferred way to indicate to maven how to find a configuration file
that
should be used? Such as, I have a persistence.xml file, currently I
have my
test database definition in it as a separate entry from my production
configuration. This works fine in theory because I can mock out my
persistence classes to use the test configuration for tests. The
problem is
that hibernate loads BOTH definitions when it starts up, whether it's used
or not which causes problems with hot deploying, when my production
environment is running (since my test config is loaded in production,
and my
tests are trying to use that configuration). I'm also running into
problems
of needing persistence configurations that can use other database servers
other than assuming localhost.
Does anyone have a strategy or know of a link that I can look at that will
help me implement an appropriate strategy to use/bundle differnet
persistence.xml files based upon the loaded maven profile? Thanks!
Ryan
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]