我的实体类中有几个@Value 注释。我不知道为什么,但他们都返回 null。我还有“ShaPasswordEncoder”Autowired 对象,它也抛出了 NullPointer 异常。我不知道为什么。请指教。
@Repository
@Configurable
@Entity
@Table(name="user")
@NamedQueries({...})
public class User implements Serializable{
@Transient private static final Logger logger = Logger.getLogger(User.class);
@Transient private static final AppUtil appUtil = new AppUtil();
@Transient @Value("some value") private String extDir;
@Transient @Value("100x100") private String imageSize;
@Transient private static byte[] salt = "FBar".getBytes();
@Transient @Autowired private ShaPasswordEncoder passwordEncoder;
....
//Default Constructor
public User(){
logger.info("TEST IMAGE => "+imageSize);
}
public String passwordEncoder(String password) {
return passwordEncoder.encodePassword(password,salt);
}