初试-springboot 遇到问题处理方案
1、entity的大小写问题
所有字段必需是驼峰写法,否认spring_boot不认可
2、前台与后台调使用的时候使用entity里面的驼峰字段,
@Column(name = “iimp_remand_id”,table=”devops_iimp”)
private? String iimpRemandId;
@Column(name = “iimp_sub_remand_id”,table=”devops_iimp”)
private? String iimpSubRemandId;
否则必需使用@JsonProperty 来标识
postman必需以这种方式调使用:

3、实体entity字段小于或者者等于repository的sql返回数据字段
4、idea的debug不能到方法那一行上,否则启动加载很慢
5、报错:
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name ‘urlPermissionsInterceptor’: Injection of resource dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name ‘aclPermissionRepository’: Cannot create inner bean ‘(inner bean)#696b32fa’ of type [org.springframework.orm.jpa.SharedEntityManagerCreator] while setting bean property ‘entityManager’; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name ‘(inner bean)#696b32fa’: Cannot resolve reference to bean ‘entityManagerFactoryDefault’ while setting constructor argument; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name ‘entityManagerFactoryDefault’ defined in class path resource [com/asiainfo/devops/gitlab/config/RepositoryDefaultConfig.class]: Invocation of init method failed; nested exception is javax.persistence.PersistenceException: [PersistenceUnit: primaryPersistenceUnit] Unable to build Hibernate SessionFactory
6、当用JPA配置实体时,假如有两个属性(一个是一般属性,一个是多对一的属性)映射到数据库的同一列,就会报错。这时,在多对一的@JoinColumn注解中增加insertable = false, updatable = false就能处理
@Column(name = “DEPT_ID”, length = 40)
private String deptId;//部门ID(IS_ORG=0的)
@ManyToOne
@JoinColumn(name = “DEPT_ID”, insertable = false, updatable = false, nullable=true)
7、@Autowired? 和 @resource的区别
使用途:做bean的注入时用
历史:@Autowired ? ? ? ?属于Spring的注解 ?org.springframework.beans.factory.annotation.Autowired
@Resource 不属于Spring的注解,JDK1.6支持的注解 javax.annotation.Resource
共同点:
装配bean. 写在字段上,或者写在setter方法
不同点:
@Autowired ?默认按类型装配?
依赖对象必需存在,假如要允许null值,可以设置它的required属性为false ? @Autowired(required=false)
也可以用名称装配,配合@Qualifier注解
1. 本站所有资源来源于用户上传和网络,如有侵权请邮件联系站长!
2. 分享目的仅供大家学习和交流,您必须在下载后24小时内删除!
3. 不得使用于非法商业用途,不得违反国家法律。否则后果自负!
4. 本站提供的源码、模板、插件等等其他资源,都不包含技术服务请大家谅解!
5. 如有链接无法下载、失效或广告,请联系管理员处理!
6. 本站资源售价只是摆设,本站源码仅提供给会员学习使用!
7. 如遇到加密压缩包,请使用360解压,如遇到无法解压的请联系管理员
开心源码网 » 初试-springboot 遇到问题处理方案