次のようなプロジェクトがあります。
Project
Project-A/
src/test/java/
someTests.java
src/test/resources
database/
create.sql
insert.sql
spring/
test-config.xml
project-B/
src/test/java
otherTests.java
Project-B のpom.xml :
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>Project-A</artifactId>
</dependency>
そして、someTests.javaで、私の構成は次のとおりです。
@RunWith(SpringJUnit4ClassRunner.class)
@WebAppConfiguration
@ContextConfiguration(locations = { "file:src/main/webapp/WEB-INF/spring/webapp-config.xml", "classpath:spring/test-dao-config.xml" })
public class DacsDAOImplTest
test-config.xml、create.sql、およびinsert.sqlをotherTests.javaで再利用したい。
私はすでにotherTests.javaで試しました
@ContextConfiguration(locations = {"classpath*:spring/test-dao-config.xml"})
しかし、これはうまくいかないようです...
編集:Geoandの回答ヘルプ、豆に関連する例外はもうありませんが、今は
FileNotFoundException: クラスパス リソース [exception-messages.properties] が存在しないため、開くことができません。
どのような変更が行われたか正確に理解していないため、これを修正する方法がわかりません... 例外メッセージはwebapp-config.xmlで次のように使用されます。<context:property-placeholder location="classpath:exception-messages.properties" />