一、vue的跨域问题
1、前端本地用代理软件代理服务器
在vue项目下的 config/index.js 文件里面配置代理proxyTable:
proxyTable: {
'/login': {
target: 'http://192.168.1.1:8080/ntd/data',
changeOrigin: true,
pathRewrite: {
'^/login':''
}
}
2、后台服务器开启允许跨域的响应头
直接在tomcat安装目录下的lib中添加cors-filter-1.7.jar,java-property-utils-1.9.jar 这2个jar包,并且在业务项目的web.xml 中配置想要应的filter配置文件:
<filter>
<filter-name>CORS</filter-name>
<filter-class>com.thetransactioncompany.cors.CORSFilter</filter-class>
</filter>
<filter-mapping>
<filter-name>CORS</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
二、Hibernate的hql不允许属性作为参数注入
三、SpringMVC注入不了泛型属性,只能注入泛型方法
(1)多Dao对象失败
public abstract class Service<T extends Serializable,D extends Dao<T>> {
//多个Dao对象会注入失败
@Autowired
protected D dao;
}
(2)正确匹配泛型
public abstract class Service<T extends Serializable,D extends Dao<T>>{
protected D dao;
@Autowired
public void setDao(D dao) {
this.dao = dao;
}
}
四、SpringMVC不能把Hibernate懒惰加载的对象转换为json
(1)在懒惰对象上加@JsonIgnore来忽视对象
(2)在对象上加fecth=Fecth.EAGER设置不懒惰加载
五、jquery跨域请求不能匹配服务端的session
解决不匹配seesion问题
$.ajax({
url:url,
//加上这两句话
xhrFields: {
withCredentials: true
},
crossDomain: true,//穿透
success:function(result){
},
error:function(){
}
});
六、Axios的post方法提交数据SpringMVC不能解析
(1)用URLSearchParams传递参数
import axios from 'axios';
let param = new URLSearchParams();
param.append("account", "admin");
param.append("password", "admin");
export async function () {
axios.post('/ntd/login', param)
}
(2)改写axios.default.transformRequest
参考axios发送post请求,springMVC接收不到数据问题
(3)将SpringMVC的@RequestParam改为@RequestBody
七、vue监视对象的属性不能直接获取vue的this对象
八、Bean类属性没有getter方法,SpringMVC的json无法解析属性
json
九、SQL的order by后直接group by无法解析group by
由于order by 优先级低,故解析不了后面的group by
十、SpringMVC的junit4无法加载context,错误为Error applying BeanValidation relational constraints
原因:hibernate验证失败。
十一、No Session found for current thread
1.事务xml配置设置proxy-target-class="true"
2.事务注解设置proxy-target-class="true"与@Transiational的类方法继承问题与接口方法继承问题
十二、SpringMVC配置事务创建不了bean
1.事务默认代理使用接口代理
2.使用cglib类代理设置proxy-target-class="true"
十三、Abandoned connection cleanup thread问题
mysql的jdbc包5.1.15的问题
十四、Hibernate的数据库连接池无法释放连接,导致请求等待
1.Hibernate的getCurrentSession方法配置事务与openSession方法必须close
2.事务的配置