我是gRPC的新手并遇到这个问题:我用rpc服务定义创建了一个.proto.编译后我得到生成的源:所有消息都有一个实现接口的类.但是,服务本身并不实现任何接口 - 它根本就不会生成.这就是我应该在我的服务器中实现的接口.我究竟做错了什么?我很确定gRPC文档没有说明这个问题.
我的.proto服务:
syntax = "proto3";
option java_multiple_files = true;
option java_package = "com.blah.my.rpc.api";
option java_outer_classname = "MyServiceProto";
option objc_class_prefix = "Pb";
package com.blah.my.rpc.api;
service MyService
{
rpc connect(PbEmptyMessage) returns (PbParameterGroup){}
rpc getParams(PbGenList) returns (PbParameterGroup){}
}
message PbEmptyMessage
{
}
message PbGenId
{
string paramName = 1;
string systemName = 2;
string sName = 3;
string sId = 4;
}
message PbParameterGroup
{
bytes sParameters = 2;
fixed64 time = 3;
}
Run Code Online (Sandbox Code Playgroud)
我在maven中的插件定义:
<extensions>
<extension>
<groupId>kr.motd.maven</groupId>
<artifactId>os-maven-plugin</artifactId>
<version>1.4.0.Final</version>
</extension> …Run Code Online (Sandbox Code Playgroud) 我正在测试一些遗留代码并尝试使用PowerMock来模拟静态方法调用.我很快发现它与类加载器混淆,这不是我觉得有资格深入研究的那种问题.仅供参考我的问题与此类似,但在我的案例中发布的解决方案不起作用.
有没有什么比PowerMock更好的替代品,我可以尝试哪些能够模拟静态,与TestNG兼容并成功用于某些现场项目?
我知道最好的选择是可测试的代码,但并不总是可以重构我当前的项目.
由于某种原因,非嵌套属性加载但嵌套不加载。
配置:
spring:
profile: junit
profiles:
include: base
Run Code Online (Sandbox Code Playgroud)
配置类:
@ConfigurationProperties(prefix = "spring")
public class MyFirstProperties {
private String profile;
private Profiles profiles;
// getters and setters
public class Profiles
{
private String include;
// getters and setters
}
}
Run Code Online (Sandbox Code Playgroud)
主要类:
@SpringBootApplication
@EnableConfigurationProperties(MyFirstProperties.class)
public class Main {
public static void main(String... args) {
SpringApplication.run(Main.class, args);
}
}
Run Code Online (Sandbox Code Playgroud)
当我将配置类注入控制器并为非嵌套属性调用 getter 时,它会返回其值。但是嵌套属性的 getter 返回 null。
使用 ConfigurationProperties 及其自己的前缀注释内部类似乎不起作用。我错过了什么吗?