---修复callservice无法正常调用bug
This commit is contained in:
@ -64,6 +64,19 @@
|
||||
<version>${revision}</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-test</artifactId>
|
||||
<scope>test</scope>
|
||||
<!-- <exclusions>
|
||||
排除JUnit 4引擎(若存在)
|
||||
<exclusion>
|
||||
<groupId>org.junit.vintage</groupId>
|
||||
<artifactId>junit-vintage-engine</artifactId>
|
||||
</exclusion>
|
||||
</exclusions> -->
|
||||
</dependency>
|
||||
|
||||
</dependencies>
|
||||
<build>
|
||||
<finalName>app</finalName>
|
||||
|
||||
@ -0,0 +1,31 @@
|
||||
package com.xjrsoft.config;
|
||||
|
||||
import org.springframework.beans.BeansException;
|
||||
import org.springframework.beans.factory.config.BeanFactoryPostProcessor;
|
||||
import org.springframework.beans.factory.config.ConfigurableListableBeanFactory;
|
||||
import org.springframework.beans.factory.support.BeanDefinitionRegistry;
|
||||
import org.springframework.beans.factory.support.BeanDefinitionRegistryPostProcessor;
|
||||
import org.springframework.beans.factory.support.DefaultListableBeanFactory;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
|
||||
@Configuration
|
||||
public class AppConfig {
|
||||
|
||||
|
||||
@Bean
|
||||
public static BeanDefinitionRegistryPostProcessor allowCircularReferences() {
|
||||
return new BeanDefinitionRegistryPostProcessor() {
|
||||
@Override
|
||||
public void postProcessBeanDefinitionRegistry(BeanDefinitionRegistry registry) {
|
||||
// 不直接强转 registry,而是在 postProcessBeanFactory 中操作 BeanFactory
|
||||
}
|
||||
|
||||
@Override
|
||||
public void postProcessBeanFactory(ConfigurableListableBeanFactory beanFactory) {
|
||||
// 此处的 beanFactory 一定是 ConfigurableListableBeanFactory 实例
|
||||
((DefaultListableBeanFactory)beanFactory).setAllowCircularReferences(true);
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,35 @@
|
||||
package com.xjrsoft.module.test.controller;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import com.xjrsoft.common.model.result.R;
|
||||
import com.xjrsoft.module.common.db.service.CommonCallService;
|
||||
import com.xjrsoft.module.dev.entity.Testfrom3;
|
||||
import com.xjrsoft.module.dev.vo.Testfrom3Vo;
|
||||
|
||||
import cn.dev33.satoken.annotation.SaCheckPermission;
|
||||
import cn.hutool.core.bean.BeanUtil;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/test/call")
|
||||
public class CallTest {
|
||||
|
||||
|
||||
// 注入待测试的服务
|
||||
@Autowired
|
||||
private CommonCallService callService;
|
||||
|
||||
@GetMapping(value = "/fSave")
|
||||
@ApiOperation(value="根据id查询Testfrom3信息")
|
||||
public R info(){
|
||||
String out = callService.saveAfter("lng_b_price_term", 12);
|
||||
System.out.println(out);
|
||||
return R.ok(null);
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,45 @@
|
||||
spring:
|
||||
cloud:
|
||||
nacos: #nacos监控
|
||||
config:
|
||||
server-addr: 47.94.165.164:8848 # nacos 配置中心地址
|
||||
namespace: ITC-MS
|
||||
group: DNE
|
||||
username: nacos
|
||||
password: Lng@123
|
||||
extension-configs:
|
||||
- data-id: global-dev.yml
|
||||
refresh: true
|
||||
group: DNE
|
||||
|
||||
- data-id: discovery-dev.yml
|
||||
refresh: true
|
||||
group: DNE
|
||||
|
||||
- data-id: datasource-dev.yml
|
||||
refresh: true
|
||||
group: DNE
|
||||
|
||||
- data-id: seata-dev.yml
|
||||
refresh: true
|
||||
group: DNE
|
||||
|
||||
- data-id: redis-dev.yml
|
||||
refresh: true
|
||||
group: DNE
|
||||
|
||||
- data-id: magic-api.yml
|
||||
refresh: true
|
||||
group: DNE
|
||||
|
||||
- data-id: sa-token.yml
|
||||
refresh: true
|
||||
group: DNE
|
||||
|
||||
- data-id: camunda.yml
|
||||
refresh: true
|
||||
group: DNE
|
||||
|
||||
- data-id: sentinel-dev.yml
|
||||
refresh: true
|
||||
group: DNE
|
||||
@ -7,7 +7,7 @@ spring:
|
||||
main:
|
||||
allow-bean-definition-overriding: true
|
||||
profiles:
|
||||
active: dev
|
||||
active: remote
|
||||
cloud:
|
||||
nacos: #nacos监控
|
||||
config:
|
||||
|
||||
@ -0,0 +1,25 @@
|
||||
package com.xjrsoft;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
import org.springframework.test.context.junit4.SpringRunner;
|
||||
import com.xjrsoft.module.common.db.service.CommonCallService;
|
||||
|
||||
@RunWith(SpringRunner.class)
|
||||
@SpringBootTest(classes = ITCDemoApplication.class)
|
||||
public class CallTest {
|
||||
|
||||
// 注入待测试的服务
|
||||
@Autowired
|
||||
private CommonCallService callService;
|
||||
|
||||
|
||||
@Test
|
||||
public void testCallSave() {
|
||||
String out = callService.saveAfter("Ing_b_price_term", 12);
|
||||
System.out.println(out);
|
||||
}
|
||||
|
||||
}
|
||||
@ -7,7 +7,7 @@ spring:
|
||||
main:
|
||||
allow-bean-definition-overriding: true
|
||||
profiles:
|
||||
active: dev
|
||||
active: remote
|
||||
cloud:
|
||||
nacos: #nacos监控
|
||||
config:
|
||||
|
||||
Reference in New Issue
Block a user