Test类注入service

1.修改.idea目录下workspace.xml文件

component目录下新增代码

<property name="dynamic.classpath" value="true" />

2.新建测试类

import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.AbstractTransactionalJUnit4SpringContextTests;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;


@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(locations = "classpath*:applicationContext.xml")
public class TycRelationShipDataTest extends AbstractTransactionalJUnit4SpringContextTests {
  
    @Autowired
    private IFileService iFileService;

     @Test
    public void testSaveAndResolve(){}
}



3.修改配置中的VM OPtions

-Xms1024M -Xmx2048M -XX:PermSize=256M -XX:MaxPermSize=512M

注意:启动方法是需要通过顶部的按钮启动,方法左侧按钮启动依然会报错

posted @ 2022-09-20 17:33  梁小白123  阅读(760)  评论(0)    收藏  举报