我正在使用cassandra、graphql和springboot2.2.0.m1进行一个测试项目。我的pom.xml中有以下依赖项
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-cassandra</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-security</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<optional>true</optional>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework.security</groupId>
<artifactId>spring-security-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-devtools</artifactId>
</dependency>
<dependency>
<groupId>com.graphql-java</groupId>
<artifactId>graphql-java-tools</artifactId>
<version>4.3.0</version>
</dependency>
<dependency>
<groupId>com.graphql-java</groupId>
<artifactId>graphql-spring-boot-starter</artifactId>
<version>4.0.0</version>
</dependency>
<dependency>
<groupId>com.graphql-java</groupId>
<artifactId>graphiql-spring-boot-starter</artifactId>
<version>4.0.0</version>
</dependency>
</dependencies>
下面是我执行死刑后在Cassandra的table DESC TABLE product
```
CREATE TABLE jerseys237.product (
prod_id timeuuid PRIMARY KEY,
available float,
description text,
discount float,
league text,
picture text,
price float,
team_country text,
team_crest text,
team_name text,
team_region text,
title text
)...
我的 `product.grapqls` 文件:
type Product {
prod_id: ID!
available: Float
description: String
discount: Float
league: String
picture: String
price: Float
team_country: String
team_crest: String
team_name: String
team_region: String
title: String
}
type Query {
findAllProducts: [Product]
findProductByPrice(price: Float!): Product
findProductByTitle(title: String!): Product
countProducts: Long
}
type Mutation {
deleteProduct(prod_id: String!) : Boolean
}
schema {
query: Query
mutation: Mutation
}
还有一个 `@Component public class Query implements GraphQLQueryResolver` 似乎没有任何问题的类。最后我有了 `Product Class` :
@Data
@NoArgsConstructor
@AllArgsConstructor
@Table
public class Product {
@PrimaryKey
private String prod_id;
private Float available;
private String description;
private Float discount;
private String league;
private String picture; // or private Byte[] picture; ??
private Float price;
private String team_country;
private String team_crest;
private String team_name;
private String team_region;
private String title;
public Product(Float available, String description, Float discount, String league, String picture, Float price, String team_country, String team_crest, String team_name, String team_region, String title) {
this.prod_id = UUIDs.timeBased().toString(); // automatically generate timeuuid
this.available = available;
this.description = description;
this.discount = discount;
this.league = league;
this.picture = picture;
this.price = price;
this.team_country = team_country;
this.team_crest = team_crest;
this.team_name = team_name;
this.team_region = team_region;
this.title = title;
}
}
正如您在cassandra键空间中看到的某些列(例如。 `team_crest` )应该是 `blob` 但我无法成功地将其Map到java类型(但这是另一个问题)。所以问题是,在更改了spring引导版本甚至依赖版本之后,每次在我的netbeans中运行应用程序时,都会出现以下错误: `com.coxautodev.graphql.tools.TypeClassMatcher$RawClassRequiredForGraphQLMappingException: Type java.util.List<com.creati.jersey.entities.Product> cannot be mapped to a GraphQL type! Since GraphQL-Java deals with erased types at runtime, only non-parameterized classes can represent a GraphQL type. This allows for reverse-lookup by java class in interfaces and union types` 如何解决此错误并使我的应用程序正常工作?
暂无答案!
目前还没有任何答案,快来回答吧!