Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/google-app-engine/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 如何调试&x27;端点框架停止生成WEB-INF/*.api文件时出错了吗?_Java_Google App Engine_Google Cloud Endpoints - Fatal编程技术网

Java 如何调试&x27;端点框架停止生成WEB-INF/*.api文件时出错了吗?

Java 如何调试&x27;端点框架停止生成WEB-INF/*.api文件时出错了吗?,java,google-app-engine,google-cloud-endpoints,Java,Google App Engine,Google Cloud Endpoints,给定Eclipse中一个Google Cloud Endpoints项目,该项目的servlet类用@Api(name=“helloworld”)注释,当项目成功编译时,Endpoints框架将生成一个名为war/WEB-INF/helloworld-v1.Api的文件。有时,即使没有编译错误,也不会生成此文件—只是我称之为“GAE端点代码约定错误” 示例-工作: public class TestEntity { public String Text; public TestE

给定Eclipse中一个Google Cloud Endpoints项目,该项目的servlet类用
@Api(name=“helloworld”)
注释,当项目成功编译时,Endpoints框架将生成一个名为
war/WEB-INF/helloworld-v1.Api
的文件。有时,即使没有编译错误,也不会生成此文件—只是我称之为“GAE端点代码约定错误”

示例-工作:

public class TestEntity {
    public String Text;
    public TestEntity(String text){
        Text = text;
    }
}

@ApiMethod
public TestEntity getTestEntity(){
    return new TestEntity("Hello world"); 
}
// The TestEntity-class is unchanged
@ApiMethod
public TestEntity getTestEntity(String input){
    return new TestEntity("Hello world"); 
}
示例-不工作:

public class TestEntity {
    public String Text;
    public TestEntity(String text){
        Text = text;
    }
}

@ApiMethod
public TestEntity getTestEntity(){
    return new TestEntity("Hello world"); 
}
// The TestEntity-class is unchanged
@ApiMethod
public TestEntity getTestEntity(String input){
    return new TestEntity("Hello world"); 
}
后一个示例的问题是,我将字符串参数作为输入,而没有使用
@Named
对其进行注释。我知道在这个例子中,但可能还有其他情况下,这不是很明显

是否有任何地方我可以阅读一些关于为什么不生成.api文件的错误日志


虽然我是一个按惯例编写代码的爱好者,但如果我不能得到关于我做错了什么的反馈,那么编程效率就要倒退一步。Eclipse提供编译器错误反馈。Google Cloud Endpoints框架应该按约定提供违反规则的代码反馈。

当代码生成失败时,当前没有良好的日志记录或错误消息,尽管这是请求的功能之一(如果不是大多数的话)。在此期间,以下是常见故障案例的列表:

  • 返回类型无效。返回类型必须是符合JavaBean约定的对象,不允许使用
    对象
    字符串
    、整数等类型
  • 一个或多个参数类型无效。方法最多可以接受
    POST
    正文中的一个对象,并且该对象还应符合JavaBean约定。方法可以通过查询字符串(使用
    @Named
    注释)接受零个或多个参数,并且这些参数必须是标量类型(例如
    string
    Integer
  • API、方法或参数的名称无效。应命名API、方法和参数以匹配以下正则表达式:
    [a-z]+[a-Za-z0-9]*
    。惯例还建议使用
    lowerCamelCase
    进行命名(尽管允许使用
    alllowercase

  • 为了给Dan的答案添加另一个提示,我发现在开发过程中,发现文件可以被我的浏览器缓存。症状是服务器上的一切看起来都正常,没有错误,但API资源管理器不显示我的API。通过打开ChromeDevTools(我已将其配置为不使用缓存),API浏览器可以工作。