我已经开始开发一个springbootdatacassandra应用程序。我正在用cassandra在springconfigurationclass中进行配置。当我启动应用程序时,它抛出syntaxerror和cassandraquerysyntaxexception。启动时,为作为帐户实体的表创建cql。它的时间戳字段是“private date createdat”。
通常,时间戳有一个“i”字符,但cql有一个“i”ı" 所以它试着运行一个cql没有ı梅斯坦普”。
Caused by: org.springframework.data.cassandra.CassandraQuerySyntaxException:
Query; CQL [CREATE TABLE IF NOT EXISTS accounts (created_at tımestamp, email text, id text,
is_active boolean, passwd text, uname text, PRIMARY KEY (id));];
line 1:49 no viable alternative at character 'ı'; nested exception is
com.datastax.oss.driver.api.core.servererrors.SyntaxError:
line 1:49 no viable alternative at character 'ı'
如何解决这个问题并继续?
我的配置类:
@Configuration
@EnableCassandraRepositories
public class CassandraConfiguration extends AbstractCassandraConfiguration {
@Value("${accountservice.cassandra.keyspace.name}")
private String keyspaceName;
@Value("${accountservice.cassandra.port}")
private int port;
@Value("${accountservice.cassandra.contact.point}")
private String contactPoint;
@Value("${accountservice.cassandra.uname}")
private String uname;
@Value("${accountservice.cassandra.passwd}")
private String passwd;
@Override
protected String getKeyspaceName() {
return keyspaceName;
}
public String getPasswd() {
return passwd;
}
public String getUname() {
return uname;
}
@Override
protected String getContactPoints() {
return contactPoint;
}
@Override
protected int getPort() {
return port;
}
@Override
public String[] getEntityBasePackages() {
return new String[] {"com.trius.accountservice"};
}
@Override
public SchemaAction getSchemaAction() {
return SchemaAction.CREATE_IF_NOT_EXISTS;
}
@Override
public CqlSessionFactoryBean cassandraSession() {
CqlSessionFactoryBean cqlSessionFactoryBean = super.cassandraSession();
cqlSessionFactoryBean.setPassword(getPasswd());
cqlSessionFactoryBean.setUsername(getUname());
return cqlSessionFactoryBean;
}
}
My Table:
@Data
@Builder
@AllArgsConstructor
@NoArgsConstructor
@EqualsAndHashCode(of = {"id"})
@ToString
@Table(value = "accounts")
public class Account implements Serializable {
@PrimaryKey
private String id = UUID.randomUUID().toString();
@Column(value="uname")
private String username;
@Column(value="email")
private String email;
@Column(value="passwd")
private String passwd;
@Column(value="is_active")
private Boolean active;
@Column(value="created_at")
private Date createdAt;
}
1条答案
按热度按时间q35jwt9p1#
似乎cql语句中无意中包含了扩展字符或特殊字符。
如果已从word文档等文件复制并粘贴了windows计算机上的架构定义,请确保先将其清除。例如,可以将模式粘贴到记事本中,并将其保存为文本文件,然后将该文件用作源文件。干杯!