pom.xml配置
<build> <finalName>vst_order</finalName> <resources> <resource> <directory>src/main/config</directory> <excludes> <exclude>*.properties</exclude> </excludes> </resource> <resource> <directory>src/main/java</directory> <includes> <include>**/*.xml</include> </includes> <filtering>false</filtering> </resource> </resources> <testResources> <testResource> <directory>src/test/config</directory> </testResource> <testResource> <directory>src/test/java</directory> </testResource> </testResources> <plugins> <plugin> <artifactId>maven-compiler-plugin</artifactId> <version>3.1</version> <configuration> <encoding>UTF-8</encoding> <source>1.6</source> <target>1.6</target> </configuration> </plugin> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-war-plugin</artifactId> <version>2.2</version> <configuration> <archiveClasses>true</archiveClasses> </configuration> </plugin> <!-- --> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-surefire-plugin</artifactId> <configuration> <skip>true</skip> </configuration> </plugin> </plugins> </build>
java目录结构
test目录下配置config目录和java目录,将所有相关配置文件放到config目录中
java代码书写
private LineProdPackageGroupService lineProdPackageGroupServiceImpl; @Before public void prepare() { String[] contextPaths = {"applicationContext-vst-order-beans.xml"}; applicationContext = new ClassPathXmlApplicationContext(contextPaths); if (this.applicationContext != null) { this.lineProdPackageGroupServiceImpl = (LineProdPackageGroupService) this.applicationContext .getBean("lineProdPackageGroupServiceImpl"); } } @Test public void testCreateProduct(){ this.lineProdPackageGroupServiceImpl.initTrafficBizInfo(null);}
转载于:https://my.oschina.net/u/1458864/blog/314912