`
wangmingyue
  • 浏览: 44749 次
  • 性别: Icon_minigender_1
  • 来自: 北京
社区版块
存档分类
最新评论

Junti4 Spring Hibernate JNDI 环境搭建

 
阅读更多

注释配置:

@RunWith(SpringJUnit4ClassRunner.class)

@ContextConfiguration(locations={"classpath:applicationContext.xml","多个文件"})


<!--数据源配置 --> 这里是重点
<bean id="dataSource" class="org.springframework.jndi.JndiObjectFactoryBean">
<property name="jndiName" value="java:comp/env/jdbc/oa2" />

<property name="resourceRef" value="true" />
<property name="defaultObject" ref="my-core-nojndi-ds" />
</bean>

<bean id="my-core-nojndi-ds"
class="org.apache.commons.dbcp.BasicDataSource">
<property name="driverClassName" value="oracle.jdbc.pool.OracleConnectionPoolDataSource" />
<property name="url"
value="jdbc:oracle:thin:username/pasword@192.168.8.75:1521:orcl" />

</bean>

加入JAR包:

commons-pool

commons-dbcp


JAVA代码:
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(locations={"classpath:applicationContext.xml","classpath:applicationContext-service.xml","classpath:applicationContext-security.xml"})
public class FlowAudiServiceTest {
@Autowired(required=true)
private LeaveWorkflowService lwf;

@BeforeClass
public static void setUpBeforeClass() throws Exception {
}

@AfterClass
public static void tearDownAfterClass() throws Exception {
}

@Before
public void setUp() throws Exception {
}

@After
public void tearDown() throws Exception {
}

@Test
public void test() {
FormLeaveInfo l = lwf.getLeave("8a8a8a67403f278201403f2a3ef60001");
System.out.println("表单编号:"+l.getFormNo());
}

}


分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics