Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/330.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 为什么这些变量没有被识别?_Java_Spring Boot_Microservices - Fatal编程技术网

Java 为什么这些变量没有被识别?

Java 为什么这些变量没有被识别?,java,spring-boot,microservices,Java,Spring Boot,Microservices,我有一个名为movie Catalog的类,试图从另一个类返回该类的列表,但是变量、名称、描述和评级没有得到识别 @RestController @请求映射/目录 公共类电影目录资源{ @RequestMapping("/{userId}") public List<CatalogItem> getCatalog(@PathVariable("userId") String userId){ return Collections.singletonList(

我有一个名为movie Catalog的类,试图从另一个类返回该类的列表,但是变量、名称、描述和评级没有得到识别

@RestController @请求映射/目录 公共类电影目录资源{

@RequestMapping("/{userId}")    
public List<CatalogItem> getCatalog(@PathVariable("userId") String 
userId){


return Collections.singletonList(
            new CatalogItem(name: "Transformer", desc:"Test", rating:4)
            );
  }
} 
下面是一个错误

这条线上有多个标记 -令牌上的语法错误:,无效 赋值运算符 -desc无法解析为变量

我已经正确导入了所有的软件包,它们都有参考资料


但是,我正在寻找代码编译,因为这些变量没有被识别出来,这是失败的。

看起来您正在尝试使用Java不支持的命名参数


如果CatalogItem的构造函数如下所示:CatalogItemString名称,String desc,int rating,您可以这样称呼它:new CatalogItemTransformer,Test,4;

您使用什么语言?