1.java注释的类型_java – 错误:注释类型不适用于这种声明

我正在尝试编译我正在编写的

Java Web应用程序,并且我遇到编译错误,我不知道该怎么做.从谷歌搜索我已经完成了,我找到了

this SO问题,但是asker正在使用EJB,而我的错误是在JPA实体类中.

这是maven构建错误.

[INFO] ------------------------------------------------------------------------

[INFO] BUILD FAILURE

[INFO] ------------------------------------------------------------------------

[INFO] Total time: 3.988s

[INFO] Finished at: Mon Jun 24 02:39:51 UTC 2013

[INFO] Final Memory: 15M/247M

[INFO] ------------------------------------------------------------------------

[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:2.3.2:compile (default-compile) on project donebox: Compilation failure: Compilation failure:

[ERROR] /home/cl-server/builder/tomcat-ide-builder/temp/build-1236514164814552082/src/main/java/net/donebox/accounts/User.java:[50,4] error: annotation type not applicable to this kind of declaration

[ERROR] /home/cl-server/builder/tomcat-ide-builder/temp/build-1236514164814552082/src/main/java/net/donebox/accounts/User.java:[60,4] error: annotation type not applicable to this kind of declaration

[ERROR] /home/cl-server/builder/tomcat-ide-builder/temp/build-1236514164814552082/src/main/java/net/donebox/accounts/Role.java:[53,4] error: annotation type not applicable to this kind of declaration

[ERROR] -> [Help 1]

[ERROR]

[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.

[ERROR] Re-run Maven using the -X switch to enable full debug logging.

[ERROR]

[ERROR] For more information about the errors and possible solutions, please read the following articles:

[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoFailureException

这是我的User类文件.

package net.donebox.accounts;

import java.io.Serializable;

import java.util.UUID;

import java.util.HashSet;

import java.util.Set;

import javax.persistence.Basic;

import javax.persistence.Cacheable;

import javax.persistence.Entity;

import javax.persistence.Id;

import javax.persistence.GeneratedValue;

import javax.persistence.Table;

import javax.persistence.Column;

import javax.persistence.Index;

import javax.persistence.ManyToMany;

import javax.persistence.JoinTable;

import org.apache.shiro.crypto.hash.Sha256Hash;

import org.apache.shiro.crypto.RandomNumberGenerator;

import org.apache.shiro.crypto.SecureRandomNumberGenerator;

@Entity

@Table(name="users")

public class User {

private UUID id;

private String username;

private String email;

private String password;

private Set roles = new HashSet();

@Id

@GeneratedValue

public UUID getId() {

return id;

}

public void setId() {

this.id = UUID.randomUUID();

}

/**

* Returns the username associated with this user account;

*

* @return the username associated with this user account;

*/

@Basic

@Column(length=100)

@Index(name="idx_users_username", columnList="username") //Error here.

public String getUsername() {

return username;

}

public void setUsername(String username) {

this.username = username;

}

@Basic

@Index(name="idx_users_email", columnList="email") // And here.

public String getEmail() {

return email;

}

public void setEmail(String email) {

this.email = email;

}

/**

* Returns the password for this user.

*

* @return this user's password

*/

@Basic(optional=false)

@Column(length=255)

public String getPassword() {

return password;

}

public void setPassword(String password) {

this.password = password;

}

@ManyToMany

@JoinTable(name="users_roles")

public Set getRoles() {

return roles;

}

public void setRoles(Set roles) {

this.roles = roles;

}

}

我查看了javax.persistence.Index JavaDoc,我的声明正确,所以我很难过,有人知道我做错了什么吗?感谢您的时间和考虑.

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值