在持久保存我的对象时,Spring Data Mongo 1.2.3.RELEASE出现了一个奇怪的问题。跟踪中有一部分:
2015-05-11 11:43:08.431 ERROR 2552 --- [nio-8080-exec-1] o.a.c.c.C.[.[.[/].
[dispatcherServlet] : Servlet.service() for servlet [dispatcherServlet]
in context with path [] threw exception [Request processing failed; nested
exception is org.springframework.data.mapping.model.MappingException:
Ambiguous field mapping detected! Both private int
java.text.NumberFormat.maximumIntegerDigits and private int
java.text.DecimalFormat.maximumIntegerDigits map to the same field name
maximumIntegerDigits! Disambiguate using @Field annotation!] with root cause
org.springframework.data.mapping.model.MappingException:
Ambiguous field mapping detected! Both private int
java.text.NumberFormat.maximumIntegerDigits and private int
java.text.DecimalFormat.maximumIntegerDigits map to the same field name
maximumIntegerDigits! Disambiguate using @Field annotation!
我的实体类是:
@Document(collection = "gab")
public class Gab implements Serializable{
@Id
private String numero;
private String nom;
private String ip;
private CustomDate gabLastConnected;
// Getters and setters ....
嵌入式文档是:
public class CustomDate {
private DateFormat format;
private Date date;
private Long annee;
private Long mois;
private Long jour;
private Long heure;
private Long minute;
private Long seconde;
// Getters ans setters
调用Mongo Repository持久性的其余方法:
@RestController
@RequestMapping("/users")
public class UsersController {
@Autowired
UserRepository userRepository;
@Autowired
private GabRepository gabRepository;
@RequestMapping(value = "/gab/ping", method = RequestMethod.GET)
public void ping_gab(Authentication authentication,HttpServletRequest request){
System.err.println("num GAB " + authentication.getName());
Gab g = gabRepository.findOne(authentication.getName());
Gab s = new Gab(g.getNumero());
s.setGabLastConnected(new CustomDate(new Date()));
System.err.println(request.getRemoteAddr());
s.setIp(request.getRemoteAddr());
System.err.println(s);
gabRepository.save(s);
}
}