Proxy error: Could not proxy request 解决方法

Posted 麻辣香猪:-D

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Proxy error: Could not proxy request 解决方法相关的知识,希望对你有一定的参考价值。

问题本质是代理失败

常见原因

1.后端相应的被代理服务器没有开启

2.代理规则写错,前后端部署的域名应一致;

3.没有把vue.config.js中的 before: require('./mock/mock-server.js'),注释掉,导致走代理前走了mockjs

4.URL前面不完整,没有http://

5.dns解析有问题,可以把target:'http://xxx' 里面的网址换成ip

6.npm install portfinder@1.0.21 安装这个低版本的模块就可以了

7.127.0.0.1偶尔不行,直接使用localhost

8.请求是否超出代理timeout,代理失败

9.node服务运行在localhost:a端口,vue运行在localhost:b端口,不同端口存在跨域问题。

需要在vue.config.js中添加

proxy:
    '/api2':
        target:'http://localhost:3000', 
        changeOrigin:true, 
    

*.更改配置后,要重启vue项目

解决springboot jpa Could not write JSON: No serializer found for class org.hibernate.proxy.pojo.javass

出现问题 

{
    "timestamp": 1583769258574,
    "status": 500,
    "error": "Internal Server Error",
    "exception": "org.springframework.http.converter.HttpMessageNotWritableException",
    "message": "Could not write JSON: No serializer found for class org.hibernate.proxy.pojo.javassist.JavassistLazyInitializer and no properties discovered to create BeanSerializer (to avoid exception, disable SerializationFeature.FAIL_ON_EMPTY_BEANS); nested exception is com.fasterxml.jackson.databind.JsonMappingException: No serializer found for class org.hibernate.proxy.pojo.javassist.JavassistLazyInitializer and no properties discovered to create BeanSerializer (to avoid exception, disable SerializationFeature.FAIL_ON_EMPTY_BEANS) (through reference chain: springboot.learn.entities.User_$$_jvst863_0["handler"])",
    "path": "/user/1",
    "company": "mg",
    "ext": null
}

解决问题 

原因

因为jsonplugin用的是Java的内审机制.hibernate会给被管理的pojo加入一个hibernateLazyInitializer属性,jsonplugin会把hibernateLazyInitializer也拿出来操作,并读取里面一个不能被反射操作的属性就产生了这个异常.

package springboot.learn.entities;


import com.fasterxml.jackson.annotation.JsonIgnoreProperties;

import javax.persistence.*;

//使用JPA 注解配置映射关系
@Entity//告诉JPA这是一个实体类 (和数据表映射的类)
@Table(name = "tpl_user")
@JsonIgnoreProperties({"hibernateLazyInitializer","handler"})// 忽略json配置
public class User {

 application.properties的配置

spring:
  datasource:
    driver-class-name: com.mysql.cj.jdbc.Driver
    url: jdbc:mysql://39.105.167.131:3306/smile_boot?serverTimezone=UTC&useUnicode=true&characterEncoding=utf-8&useSSL=true
    username: root
    password: Nrblwbb7$

  jpa:
    properties:
      hibernate:
        hbm2ddl:
          auto: update #数据库表的migration
        dialect: org.hibernate.dialect.MySQL5InnoDBDialect #规定数据库未innodb型
        format_sql: true
    show-sql: true#在控制台打印sql

 

以上是关于Proxy error: Could not proxy request 解决方法的主要内容,如果未能解决你的问题,请参考以下文章

Proxy error: Could not proxy request xxx from localhost:8080 to http://localhost:3000(ECONNREFUSED)

Jmeter常见报错信息: ERROR - jmeter.protocol.http.proxy.ProxyControl: Could not initialise key store java.i

解决springboot jpa Could not write JSON: No serializer found for class org.hibernate.proxy.pojo.javass

git call failed: [git clone Could not resolve host: git.openstack.org

could not initialize proxy - no Session

could not initialize proxy - no Session