问题描述
我正在尝试使用我的 Spring Boot 项目连接到 influxdb,该项目可以轻松连接到 postgres 数据库。这是我的应用程序属性:
### Application server ###
server.port=8088
### DATABASE POSTGRES LOCAL ###
#spring.jpa.hibernate.ddl-auto=update
spring.datasource.url=jdbc:postgresql://localhost:5432/xxxxres
spring.datasource.username=xxxx
spring.datasource.password=xxxx
### INFLUX ###
spring.influx.url=https://xxxxxx.it:66xx3
spring.influx.user=admin
spring.influx.password=xxx
spring.influx.database=xxx
我创建了一些与 postgres 一起使用的 REST 调用,但我不能在涌入时做同样的事情。我的疑问是与 influx db 的联系。
这是我的 Influx 实体:
@Measurement(name = "M_M_TEST")
public class MMEntity {
@Column(name = "Time")
private Integer time;
@Column(name = "DUL5_L1_AUX_OTH_OTH_OTH.Active_Energy")
private Integer DUL5_L1_AUX_OTH_OTH_OTH_Active_Energy;
@Column(name = "DUL5_L1_AUX_OTH_OTH_OTH.Active_Power")
private Integer DUL5_L1_AUX_OTH_OTH_OTH_Active_Power;
}
这是我的模型:
@Measurement(name = "M_M_TEST")
public class MMModel {
private Integer time;
private Integer DUL5_L1_AUX_OTH_OTH_OTH_Active_Energy;
private Integer DUL5_L1_AUX_OTH_OTH_OTH_Active_Power;
//GETTER & SETTER
}
这是我的控制器:
@Api(tags = { SwaggerTags.TAG_M_M_NAME })
@RequestMapping("/v1/basePath")
@RestController
@EnableGlobalMethodSecurity(prePostEnabled = true,securedEnabled = true)
public class MMController extends AbstractController{
private static final Logger logger = LoggerFactory.getLogger(MMController.class);
@Autowired
MMService mMService;
@ApiOperation(value = "Finds all values of MM")
@GetMapping("/M-M/all")
public List<MMModel> findAll() {
final String METHOD_NAME = "findAll()";
try {
startLog(METHOD_NAME);
final List<MonterotondoMarittimoEntity> result = monterotondoMarittimoService.findAll();
final List<MonterotondoMarittimoModel> response = ModelMapUtils.createObject(result,MonterotondoMarittimoModel.class);
endLog(METHOD_NAME,response);
return response;
} catch (final Exception e) {
errorLog(METHOD_NAME,e);
throw e;
}
}
}
这是我的服务:
@Service
public class MonterotondoMarittimoService extends AbstractService {
@Autowired
InfluxDB influxDB;
@Value("${spring.influx.url}")
private String influxDBUrl;
@Value("${spring.influx.user}")
private String userName;
@Value("${spring.influx.password}")
private String password;
@Value("${spring.influx.database}")
private String database;
@Transactional
public List<MMEntity> findAll() {
final String METHOD_NAME = "findAll()";
startLog(METHOD_NAME);
List<MMEntity> result = new ArrayList<MMEntity>();
final Query query = new Query("SELECT * FROM M_M LIMIT 10",database);
QueryResult queryResult = influxDB.query(query);
InfluxDBResultMapper resultMapper = new InfluxDBResultMapper();
result = resultMapper.toPOJO(queryResult,MMEntity.class);
endLog(METHOD_NAME,result);
return result;
}
}
我想使用 findAll 方法获取表 M_M 中存在的所有元素。
但是当我使用 Swagger 执行该方法时,此日志出现 500 错误 ("org.influxdb.InfluxDBIOException: javax.net.ssl.SSLHandshakeException: PKIX path building Failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target")
是否需要一个类来配置与 Influx 的连接?
我能做些什么来解决我的问题?
请帮帮我。
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)