会员可以在此提问,百战程序员老师有问必答
对大家有帮助的问答会被标记为“推荐”
看完课程过来浏览一下别人提的问题,会帮你学得更全面
截止目前,同学们一共提了 132422个问题
Python 全系列/第三阶段:Python 网络与并发编程/并发编程 32673楼

老师我的课堂作业这么写可以吗?可能比较低端

代码如下:

com.bjst.array;

Test02 {
    main(String[] args) {


        Sp sp0 =Sp(,,,,);
        Sp sp1 =Sp(,,,,);
        Sp sp2 =Sp(,,,,);
        Sp sp3 =Sp(,,,,);
        Sp sp4 =Sp(,,,,);

        Sp[] sps=Sp[];

        sps[]=sp0;
        sps[]=sp1;
        sps[]=sp2;
        sps[]=sp3;
        sps[]=sp4;

        (i = ; i < sps.; i++) {
                m = ;
                getJiage_zhekou = sps[i].getJiage() * sps[i].getZhekou();
                (m < getJiage_zhekou) {
System..println(sps[i].getId()++sps[i].getName()++sps[i].getXinghao()++sps[i].getJiage()++sps[i].getZhekou()+++getJiage_zhekou);
                }{
                    System..println(sps[i].getName()+);
                }
            }
        }




}
Sp{
    ;

    String ;

    String ;

    ;

    ;

    ;

    Sp(id, String name, String xinghao, jiage, zhekou) {
        .= id;
        .= name;
        .= xinghao;
        .= jiage;
        .= zhekou;
    }


    getJiage_zhekou() {
        ;
    }

    setJiage_zhekou(jiage_zhekou) {
        .= jiage_zhekou;
    }

    getId() {
        ;
    }

    setId(id) {
        .= id;
    }

    String getName() {
        ;
    }

    setName(String name) {
        .= name;
    }

    String getXinghao() {
        ;
    }

    setXinghao(String xinghao) {
        .= xinghao;
    }

    getJiage() {
        ;
    }

    setJiage(jiage) {
        .= jiage;
    }

    getZhekou() {
        ;
    }

    setZhekou(zhekou) {
        .= zhekou;
    }
    Sp(){}

    String toString() {
        +
                + +
                + + +
                + + +
                + +
                + +
                ;
    }
}

运行结果


百战牌鼠标价格太低了
2    键盘侠玩偶    WO_102    403.0    0.7    折后价格为282.09999999999997
实战java程序设计价格太低了
4    高淇牌西装    GQ_XF_12    700.0    0.5    折后价格为350.0
5    大米牌手机    DM_PH_13    900.0    0.3    折后价格为270.0

Process finished with exit code 0


JAVA 全系列/第一阶段:JAVA 快速入门/数组和数据存储 32675楼

启动ProviderApplication时错误显示如下,防火墙已经关闭,zookeeper已经启动

"C:\Program Files\Java\jdk-13.0.2\bin\java.exe" -XX:TieredStopAtLevel=1 -noverify -Dspring.output.ansi.enabled=always -Dcom.sun.management.jmxremote -Dspring.jmx.enabled=true -Dspring.liveBeansView.mbeanDomain -Dspring.application.admin.enabled=true "-javaagent:C:\Program Files\JetBrains\IntelliJ IDEA 2019.3.2\lib\idea_rt.jar=54795:C:\Program Files\JetBrains\IntelliJ IDEA 2019.3.2\bin" -Dfile.encoding=UTF-8 -classpath D:\myjava\第十七阶段\4\4\源码\ego_parent\ego_provider\target\classes;D:\myjava\第十七阶段\4\4\源码\ego_parent\ego_api\target\classes;D:\myjava\第十七阶段\4\4\源码\ego_parent\ego_pojo\target\classes;D:\myjava\第十七阶段\4\4\源码\ego_parent\ego_commons\target\classes;C:\Users\cxs\.m2\repository\cn\bestwu\fastdfs-client-java\1.27\fastdfs-client-java-1.27.jar;C:\Users\cxs\.m2\repository\org\apache\commons\commons-lang3\3.4\commons-lang3-3.4.jar;D:\myjava\第十七阶段\4\4\源码\ego_parent\ego_mapper\target\classes;C:\Users\cxs\.m2\repository\org\mybatis\spring\boot\mybatis-spring-boot-starter\2.1.1\mybatis-spring-boot-starter-2.1.1.jar;C:\Users\cxs\.m2\repository\org\springframework\boot\spring-boot-starter-jdbc\2.2.5.RELEASE\spring-boot-starter-jdbc-2.2.5.RELEASE.jar;C:\Users\cxs\.m2\repository\com\zaxxer\HikariCP\3.4.2\HikariCP-3.4.2.jar;C:\Users\cxs\.m2\repository\org\springframework\spring-jdbc\5.2.4.RELEASE\spring-jdbc-5.2.4.RELEASE.jar;C:\Users\cxs\.m2\repository\org\springframework\spring-tx\5.2.4.RELEASE\spring-tx-5.2.4.RELEASE.jar;C:\Users\cxs\.m2\repository\org\mybatis\spring\boot\mybatis-spring-boot-autoconfigure\2.1.1\mybatis-spring-boot-autoconfigure-2.1.1.jar;C:\Users\cxs\.m2\repository\org\mybatis\mybatis\3.5.3\mybatis-3.5.3.jar;C:\Users\cxs\.m2\repository\org\mybatis\mybatis-spring\2.0.3\mybatis-spring-2.0.3.jar;C:\Users\cxs\.m2\repository\mysql\mysql-connector-java\5.1.48\mysql-connector-java-5.1.48.jar;C:\Users\cxs\.m2\repository\com\alibaba\druid-spring-boot-starter\1.1.10\druid-spring-boot-starter-1.1.10.jar;C:\Users\cxs\.m2\repository\com\alibaba\druid\1.1.10\druid-1.1.10.jar;C:\Users\cxs\.m2\repository\org\slf4j\slf4j-api\1.7.30\slf4j-api-1.7.30.jar;C:\Users\cxs\.m2\repository\org\springframework\boot\spring-boot-starter\2.2.5.RELEASE\spring-boot-starter-2.2.5.RELEASE.jar;C:\Users\cxs\.m2\repository\org\springframework\boot\spring-boot\2.2.5.RELEASE\spring-boot-2.2.5.RELEASE.jar;C:\Users\cxs\.m2\repository\org\springframework\spring-context\5.2.4.RELEASE\spring-context-5.2.4.RELEASE.jar;C:\Users\cxs\.m2\repository\org\springframework\spring-aop\5.2.4.RELEASE\spring-aop-5.2.4.RELEASE.jar;C:\Users\cxs\.m2\repository\org\springframework\spring-beans\5.2.4.RELEASE\spring-beans-5.2.4.RELEASE.jar;C:\Users\cxs\.m2\repository\org\springframework\spring-expression\5.2.4.RELEASE\spring-expression-5.2.4.RELEASE.jar;C:\Users\cxs\.m2\repository\org\springframework\boot\spring-boot-autoconfigure\2.2.5.RELEASE\spring-boot-autoconfigure-2.2.5.RELEASE.jar;C:\Users\cxs\.m2\repository\org\springframework\boot\spring-boot-starter-logging\2.2.5.RELEASE\spring-boot-starter-logging-2.2.5.RELEASE.jar;C:\Users\cxs\.m2\repository\ch\qos\logback\logback-classic\1.2.3\logback-classic-1.2.3.jar;C:\Users\cxs\.m2\repository\ch\qos\logback\logback-core\1.2.3\logback-core-1.2.3.jar;C:\Users\cxs\.m2\repository\org\apache\logging\log4j\log4j-to-slf4j\2.12.1\log4j-to-slf4j-2.12.1.jar;C:\Users\cxs\.m2\repository\org\apache\logging\log4j\log4j-api\2.12.1\log4j-api-2.12.1.jar;C:\Users\cxs\.m2\repository\org\slf4j\jul-to-slf4j\1.7.30\jul-to-slf4j-1.7.30.jar;C:\Users\cxs\.m2\repository\jakarta\annotation\jakarta.annotation-api\1.3.5\jakarta.annotation-api-1.3.5.jar;C:\Users\cxs\.m2\repository\org\springframework\spring-core\5.2.4.RELEASE\spring-core-5.2.4.RELEASE.jar;C:\Users\cxs\.m2\repository\org\springframework\spring-jcl\5.2.4.RELEASE\spring-jcl-5.2.4.RELEASE.jar;C:\Users\cxs\.m2\repository\org\yaml\snakeyaml\1.25\snakeyaml-1.25.jar;C:\Users\cxs\.m2\repository\org\apache\dubbo\dubbo-spring-boot-starter\2.7.5\dubbo-spring-boot-starter-2.7.5.jar;C:\Users\cxs\.m2\repository\org\apache\dubbo\dubbo-spring-boot-autoconfigure\2.7.5\dubbo-spring-boot-autoconfigure-2.7.5.jar;C:\Users\cxs\.m2\repository\org\apache\dubbo\dubbo-spring-boot-autoconfigure-compatible\2.7.5\dubbo-spring-boot-autoconfigure-compatible-2.7.5.jar;C:\Users\cxs\.m2\repository\org\apache\dubbo\dubbo\2.7.5\dubbo-2.7.5.jar;C:\Users\cxs\.m2\repository\com\alibaba\spring\spring-context-support\1.0.5\spring-context-support-1.0.5.jar;C:\Users\cxs\.m2\repository\org\javassist\javassist\3.20.0-GA\javassist-3.20.0-GA.jar;C:\Users\cxs\.m2\repository\io\netty\netty-all\4.1.45.Final\netty-all-4.1.45.Final.jar;C:\Users\cxs\.m2\repository\com\google\code\gson\gson\2.8.6\gson-2.8.6.jar;C:\Users\cxs\.m2\repository\org\apache\curator\curator-recipes\4.0.1\curator-recipes-4.0.1.jar;C:\Users\cxs\.m2\repository\org\apache\curator\curator-framework\4.0.1\curator-framework-4.0.1.jar;C:\Users\cxs\.m2\repository\org\apache\curator\curator-client\4.0.1\curator-client-4.0.1.jar;C:\Users\cxs\.m2\repository\org\apache\zookeeper\zookeeper\3.5.3-beta\zookeeper-3.5.3-beta.jar;C:\Users\cxs\.m2\repository\commons-cli\commons-cli\1.2\commons-cli-1.2.jar;C:\Users\cxs\.m2\repository\log4j\log4j\1.2.17\log4j-1.2.17.jar;C:\Users\cxs\.m2\repository\io\netty\netty\3.10.5.Final\netty-3.10.5.Final.jar;C:\Users\cxs\.m2\repository\com\google\guava\guava\20.0\guava-20.0.jar;C:\Users\cxs\.m2\repository\com\github\pagehelper\pagehelper-spring-boot-starter\1.2.13\pagehelper-spring-boot-starter-1.2.13.jar;C:\Users\cxs\.m2\repository\com\github\pagehelper\pagehelper-spring-boot-autoconfigure\1.2.13\pagehelper-spring-boot-autoconfigure-1.2.13.jar;C:\Users\cxs\.m2\repository\com\github\pagehelper\pagehelper\5.1.11\pagehelper-5.1.11.jar;C:\Users\cxs\.m2\repository\com\github\jsqlparser\jsqlparser\2.0\jsqlparser-2.0.jar com.ego.ProviderApplication
Java HotSpot(TM) 64-Bit Server VM warning: Options -Xverify:none and -noverify were deprecated in JDK 13 and will likely be removed in a future release.
log4j:WARN No appenders could be found for logger (org.apache.dubbo.common.logger.LoggerFactory).
log4j:WARN Please initialize the log4j system properly.
log4j:WARN See http://logging.apache.org/log4j/1.2/faq.html#noconfig for more info.
2020-05-13 18:51:13.147  INFO 12848 --- [           main] d.s.b.c.e.WelcomeLogoApplicationListener :
 :: Dubbo Spring Boot (v2.7.5) : https://github.com/apache/dubbo-spring-boot-project
 :: Dubbo (v2.7.5) : https://github.com/apache/dubbo
 :: Discuss group : dev@dubbo.apache.org
2020-05-13 18:51:13.151  INFO 12848 --- [           main] e.OverrideDubboConfigApplicationListener : Dubbo Config was overridden by externalized configuration {dubbo.application.name=ego-provider, dubbo.application.qos-enable=false, dubbo.config.multiple=true, dubbo.registry.address=zookeeper://192.168.8.128:2181}
  .   ____          _            __ _ _
 /\\ / ___'_ __ _ _(_)_ __  __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
 \\/  ___)| |_)| | | | | || (_| |  ) ) ) )
  '  |____| .__|_| |_|_| |_\__, | / / / /
 =========|_|==============|___/=/_/_/_/
 :: Spring Boot ::        (v2.2.5.RELEASE)
2020-05-13 18:51:13.231  INFO 12848 --- [           main] com.ego.ProviderApplication              : Starting ProviderApplication on DESKTOP-7SEAAAI with PID 12848 (started by cxs in D:\myjava\第十七阶段\4\4\源码\ego_parent)
2020-05-13 18:51:13.232  INFO 12848 --- [           main] com.ego.ProviderApplication              : The following profiles are active: mapper
2020-05-13 18:51:13.303  INFO 12848 --- [           main] com.alibaba.spring.util.BeanRegistrar    : The Infrastructure bean definition [Root bean: class [org.apache.dubbo.spring.boot.beans.factory.config.DubboConfigBeanCustomizer]; scope=; abstract=false; lazyInit=null; autowireMode=0; dependencyCheck=0; autowireCandidate=true; primary=false; factoryBeanName=null; factoryMethodName=null; initMethodName=null; destroyMethodName=nullwith name [namePropertyDefaultValueDubboConfigBeanCustomizer] has been registered.
2020-05-13 18:51:13.602  INFO 12848 --- [           main] com.alibaba.spring.util.BeanRegistrar    : The Infrastructure bean definition [Root bean: class [org.apache.dubbo.config.spring.beans.factory.annotation.DubboConfigAliasPostProcessor]; scope=; abstract=false; lazyInit=null; autowireMode=0; dependencyCheck=0; autowireCandidate=true; primary=false; factoryBeanName=null; factoryMethodName=null; initMethodName=null; destroyMethodName=nullwith name [dubboConfigAliasPostProcessor] has been registered.
2020-05-13 18:51:13.603  INFO 12848 --- [           main] com.alibaba.spring.util.BeanRegistrar    : The Infrastructure bean definition [Root bean: class [org.apache.dubbo.config.spring.beans.factory.annotation.ReferenceAnnotationBeanPostProcessor]; scope=; abstract=false; lazyInit=null; autowireMode=0; dependencyCheck=0; autowireCandidate=true; primary=false; factoryBeanName=null; factoryMethodName=null; initMethodName=null; destroyMethodName=nullwith name [referenceAnnotationBeanPostProcessor] has been registered.
2020-05-13 18:51:13.644  INFO 12848 --- [           main] .b.f.a.ConfigurationBeanBindingRegistrar : The configuration bean definition [name : org.apache.dubbo.config.ApplicationConfig#0, content : Root bean: class [org.apache.dubbo.config.ApplicationConfig]; scope=; abstract=false; lazyInit=null; autowireMode=0; dependencyCheck=0; autowireCandidate=true; primary=false; factoryBeanName=null; factoryMethodName=null; initMethodName=null; destroyMethodName=null] has been registered.
2020-05-13 18:51:13.644  INFO 12848 --- [           main] com.alibaba.spring.util.BeanRegistrar    : The Infrastructure bean definition [Root bean: class [com.alibaba.spring.beans.factory.annotation.ConfigurationBeanBindingPostProcessor]; scope=; abstract=false; lazyInit=null; autowireMode=0; dependencyCheck=0; autowireCandidate=true; primary=false; factoryBeanName=null; factoryMethodName=null; initMethodName=null; destroyMethodName=nullwith name [configurationBeanBindingPostProcessor] has been registered.
2020-05-13 18:51:13.644  INFO 12848 --- [           main] .b.f.a.ConfigurationBeanBindingRegistrar : The configuration bean definition [name : org.apache.dubbo.config.RegistryConfig#0, content : Root bean: class [org.apache.dubbo.config.RegistryConfig]; scope=; abstract=false; lazyInit=null; autowireMode=0; dependencyCheck=0; autowireCandidate=true; primary=false; factoryBeanName=null; factoryMethodName=null; initMethodName=null; destroyMethodName=null] has been registered.
2020-05-13 18:51:14.023  INFO 12848 --- [           main] c.a.d.s.b.a.DruidDataSourceAutoConfigure : Init DruidDataSource
2020-05-13 18:51:14.259  INFO 12848 --- [           main] com.alibaba.druid.pool.DruidDataSource   : {dataSource-1} inited
2020-05-13 18:51:14.676  INFO 12848 --- [           main] .a.ConfigurationBeanBindingPostProcessor : The configuration bean [<dubbo:application name="ego-provider" valid="true" hostname="DESKTOP-7SEAAAI" qosEnable="false" qosEnableCompatible="false" id="ego-provider" prefix="dubbo.application" />] have been binding by the configuration properties [{name=ego-provider, qos-enable=false}]
2020-05-13 18:51:14.680  INFO 12848 --- [           main] .a.ConfigurationBeanBindingPostProcessor : The configuration bean [<dubbo:registry address="zookeeper://192.168.8.128:2181" port="2181" protocol="zookeeper" valid="true" id="zookeeper" prefix="dubbo.registry" />] have been binding by the configuration properties [{address=zookeeper://192.168.8.128:2181}]
WARNING: An illegal reflective access operation has occurred
WARNING: Illegal reflective access by javassist.ClassPool (file:/C:/Users/cxs/.m2/repository/org/javassist/javassist/3.20.0-GA/javassist-3.20.0-GA.jar) to method java.lang.ClassLoader.defineClass(java.lang.String,byte[],int,int,java.security.ProtectionDomain)
WARNING: Please consider reporting this to the maintainers of javassist.ClassPool
WARNING: Use --illegal-access=warn to enable warnings of further illegal reflective access operations
WARNING: All illegal access operations will be denied in a future release
2020-05-13 18:51:19.574  INFO 12848 --- [           main] org.apache.zookeeper.ZooKeeper           : Client environment:zookeeper.version=3.5.3-beta-8ce24f9e675cbefffb8f21a47e06b42864475a60, built on 04/03/2017 16:19 GMT
2020-05-13 18:51:19.574  INFO 12848 --- [           main] org.apache.zookeeper.ZooKeeper           : Client environment:host.name=DESKTOP-7SEAAAI
2020-05-13 18:51:19.574  INFO 12848 --- [           main] org.apache.zookeeper.ZooKeeper           : Client environment:java.version=13.0.2
2020-05-13 18:51:19.574  INFO 12848 --- [           main] org.apache.zookeeper.ZooKeeper           : Client environment:java.vendor=Oracle Corporation
2020-05-13 18:51:19.574  INFO 12848 --- [           main] org.apache.zookeeper.ZooKeeper           : Client environment:java.home=C:\Program Files\Java\jdk-13.0.2
2020-05-13 18:51:19.574  INFO 12848 --- [           main] org.apache.zookeeper.ZooKeeper           : Client environment:java.class.path=D:\myjava\第十七阶段\4\4\源码\ego_parent\ego_provider\target\classes;D:\myjava\第十七阶段\4\4\源码\ego_parent\ego_api\target\classes;D:\myjava\第十七阶段\4\4\源码\ego_parent\ego_pojo\target\classes;D:\myjava\第十七阶段\4\4\源码\ego_parent\ego_commons\target\classes;C:\Users\cxs\.m2\repository\cn\bestwu\fastdfs-client-java\1.27\fastdfs-client-java-1.27.jar;C:\Users\cxs\.m2\repository\org\apache\commons\commons-lang3\3.4\commons-lang3-3.4.jar;D:\myjava\第十七阶段\4\4\源码\ego_parent\ego_mapper\target\classes;C:\Users\cxs\.m2\repository\org\mybatis\spring\boot\mybatis-spring-boot-starter\2.1.1\mybatis-spring-boot-starter-2.1.1.jar;C:\Users\cxs\.m2\repository\org\springframework\boot\spring-boot-starter-jdbc\2.2.5.RELEASE\spring-boot-starter-jdbc-2.2.5.RELEASE.jar;C:\Users\cxs\.m2\repository\com\zaxxer\HikariCP\3.4.2\HikariCP-3.4.2.jar;C:\Users\cxs\.m2\repository\org\springframework\spring-jdbc\5.2.4.RELEASE\spring-jdbc-5.2.4.RELEASE.jar;C:\Users\cxs\.m2\repository\org\springframework\spring-tx\5.2.4.RELEASE\spring-tx-5.2.4.RELEASE.jar;C:\Users\cxs\.m2\repository\org\mybatis\spring\boot\mybatis-spring-boot-autoconfigure\2.1.1\mybatis-spring-boot-autoconfigure-2.1.1.jar;C:\Users\cxs\.m2\repository\org\mybatis\mybatis\3.5.3\mybatis-3.5.3.jar;C:\Users\cxs\.m2\repository\org\mybatis\mybatis-spring\2.0.3\mybatis-spring-2.0.3.jar;C:\Users\cxs\.m2\repository\mysql\mysql-connector-java\5.1.48\mysql-connector-java-5.1.48.jar;C:\Users\cxs\.m2\repository\com\alibaba\druid-spring-boot-starter\1.1.10\druid-spring-boot-starter-1.1.10.jar;C:\Users\cxs\.m2\repository\com\alibaba\druid\1.1.10\druid-1.1.10.jar;C:\Users\cxs\.m2\repository\org\slf4j\slf4j-api\1.7.30\slf4j-api-1.7.30.jar;C:\Users\cxs\.m2\repository\org\springframework\boot\spring-boot-starter\2.2.5.RELEASE\spring-boot-starter-2.2.5.RELEASE.jar;C:\Users\cxs\.m2\repository\org\springframework\boot\spring-boot\2.2.5.RELEASE\spring-boot-2.2.5.RELEASE.jar;C:\Users\cxs\.m2\repository\org\springframework\spring-context\5.2.4.RELEASE\spring-context-5.2.4.RELEASE.jar;C:\Users\cxs\.m2\repository\org\springframework\spring-aop\5.2.4.RELEASE\spring-aop-5.2.4.RELEASE.jar;C:\Users\cxs\.m2\repository\org\springframework\spring-beans\5.2.4.RELEASE\spring-beans-5.2.4.RELEASE.jar;C:\Users\cxs\.m2\repository\org\springframework\spring-expression\5.2.4.RELEASE\spring-expression-5.2.4.RELEASE.jar;C:\Users\cxs\.m2\repository\org\springframework\boot\spring-boot-autoconfigure\2.2.5.RELEASE\spring-boot-autoconfigure-2.2.5.RELEASE.jar;C:\Users\cxs\.m2\repository\org\springframework\boot\spring-boot-starter-logging\2.2.5.RELEASE\spring-boot-starter-logging-2.2.5.RELEASE.jar;C:\Users\cxs\.m2\repository\ch\qos\logback\logback-classic\1.2.3\logback-classic-1.2.3.jar;C:\Users\cxs\.m2\repository\ch\qos\logback\logback-core\1.2.3\logback-core-1.2.3.jar;C:\Users\cxs\.m2\repository\org\apache\logging\log4j\log4j-to-slf4j\2.12.1\log4j-to-slf4j-2.12.1.jar;C:\Users\cxs\.m2\repository\org\apache\logging\log4j\log4j-api\2.12.1\log4j-api-2.12.1.jar;C:\Users\cxs\.m2\repository\org\slf4j\jul-to-slf4j\1.7.30\jul-to-slf4j-1.7.30.jar;C:\Users\cxs\.m2\repository\jakarta\annotation\jakarta.annotation-api\1.3.5\jakarta.annotation-api-1.3.5.jar;C:\Users\cxs\.m2\repository\org\springframework\spring-core\5.2.4.RELEASE\spring-core-5.2.4.RELEASE.jar;C:\Users\cxs\.m2\repository\org\springframework\spring-jcl\5.2.4.RELEASE\spring-jcl-5.2.4.RELEASE.jar;C:\Users\cxs\.m2\repository\org\yaml\snakeyaml\1.25\snakeyaml-1.25.jar;C:\Users\cxs\.m2\repository\org\apache\dubbo\dubbo-spring-boot-starter\2.7.5\dubbo-spring-boot-starter-2.7.5.jar;C:\Users\cxs\.m2\repository\org\apache\dubbo\dubbo-spring-boot-autoconfigure\2.7.5\dubbo-spring-boot-autoconfigure-2.7.5.jar;C:\Users\cxs\.m2\repository\org\apache\dubbo\dubbo-spring-boot-autoconfigure-compatible\2.7.5\dubbo-spring-boot-autoconfigure-compatible-2.7.5.jar;C:\Users\cxs\.m2\repository\org\apache\dubbo\dubbo\2.7.5\dubbo-2.7.5.jar;C:\Users\cxs\.m2\repository\com\alibaba\spring\spring-context-support\1.0.5\spring-context-support-1.0.5.jar;C:\Users\cxs\.m2\repository\org\javassist\javassist\3.20.0-GA\javassist-3.20.0-GA.jar;C:\Users\cxs\.m2\repository\io\netty\netty-all\4.1.45.Final\netty-all-4.1.45.Final.jar;C:\Users\cxs\.m2\repository\com\google\code\gson\gson\2.8.6\gson-2.8.6.jar;C:\Users\cxs\.m2\repository\org\apache\curator\curator-recipes\4.0.1\curator-recipes-4.0.1.jar;C:\Users\cxs\.m2\repository\org\apache\curator\curator-framework\4.0.1\curator-framework-4.0.1.jar;C:\Users\cxs\.m2\repository\org\apache\curator\curator-client\4.0.1\curator-client-4.0.1.jar;C:\Users\cxs\.m2\repository\org\apache\zookeeper\zookeeper\3.5.3-beta\zookeeper-3.5.3-beta.jar;C:\Users\cxs\.m2\repository\commons-cli\commons-cli\1.2\commons-cli-1.2.jar;C:\Users\cxs\.m2\repository\log4j\log4j\1.2.17\log4j-1.2.17.jar;C:\Users\cxs\.m2\repository\io\netty\netty\3.10.5.Final\netty-3.10.5.Final.jar;C:\Users\cxs\.m2\repository\com\google\guava\guava\20.0\guava-20.0.jar;C:\Users\cxs\.m2\repository\com\github\pagehelper\pagehelper-spring-boot-starter\1.2.13\pagehelper-spring-boot-starter-1.2.13.jar;C:\Users\cxs\.m2\repository\com\github\pagehelper\pagehelper-spring-boot-autoconfigure\1.2.13\pagehelper-spring-boot-autoconfigure-1.2.13.jar;C:\Users\cxs\.m2\repository\com\github\pagehelper\pagehelper\5.1.11\pagehelper-5.1.11.jar;C:\Users\cxs\.m2\repository\com\github\jsqlparser\jsqlparser\2.0\jsqlparser-2.0.jar
2020-05-13 18:51:19.575  INFO 12848 --- [           main] org.apache.zookeeper.ZooKeeper           : Client environment:java.library.path=C:\Program Files\Java\jdk-13.0.2\bin;C:\Windows\Sun\Java\bin;C:\Windows\system32;C:\Windows;D:\app\cxs\product\11.2.0\dbhome_1\bin;C:\Program Files\Java\jdk-13.0.2\bin;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Windows\System32\OpenSSH\;C:\Program Files (x86)\NVIDIA Corporation\PhysX\Common;C:\Program Files\NVIDIA Corporation\NVIDIA NvDLISR;C:\Program Files\Intel\WiFi\bin\;C:\Program Files\Common Files\Intel\WirelessCommon\;C:\Program Files\MySQL\bin;C:\Users\cxs\AppData\Local\Microsoft\WindowsApps;;.
2020-05-13 18:51:19.575  INFO 12848 --- [           main] org.apache.zookeeper.ZooKeeper           : Client environment:java.io.tmpdir=C:\Users\cxs\AppData\Local\Temp\
2020-05-13 18:51:19.575  INFO 12848 --- [           main] org.apache.zookeeper.ZooKeeper           : Client environment:java.compiler=<NA>
2020-05-13 18:51:19.575  INFO 12848 --- [           main] org.apache.zookeeper.ZooKeeper           : Client environment:os.name=Windows 10
2020-05-13 18:51:19.575  INFO 12848 --- [           main] org.apache.zookeeper.ZooKeeper           : Client environment:os.arch=amd64
2020-05-13 18:51:19.575  INFO 12848 --- [           main] org.apache.zookeeper.ZooKeeper           : Client environment:os.version=10.0
2020-05-13 18:51:19.575  INFO 12848 --- [           main] org.apache.zookeeper.ZooKeeper           : Client environment:user.name=cxs
2020-05-13 18:51:19.575  INFO 12848 --- [           main] org.apache.zookeeper.ZooKeeper           : Client environment:user.home=C:\Users\cxs
2020-05-13 18:51:19.575  INFO 12848 --- [           main] org.apache.zookeeper.ZooKeeper           : Client environment:user.dir=D:\myjava\第十七阶段\4\4\源码\ego_parent
2020-05-13 18:51:19.575  INFO 12848 --- [           main] org.apache.zookeeper.ZooKeeper           : Client environment:os.memory.free=15MB
2020-05-13 18:51:19.575  INFO 12848 --- [           main] org.apache.zookeeper.ZooKeeper           : Client environment:os.memory.max=2008MB
2020-05-13 18:51:19.575  INFO 12848 --- [           main] org.apache.zookeeper.ZooKeeper           : Client environment:os.memory.total=57MB
2020-05-13 18:51:19.602  INFO 12848 --- [           main] o.a.c.f.imps.CuratorFrameworkImpl        : Starting
2020-05-13 18:51:19.605  INFO 12848 --- [           main] org.apache.zookeeper.ZooKeeper           : Initiating client connection, connectString=192.168.8.128:2181 sessionTimeout=60000 watcher=org.apache.curator.ConnectionState@33bb3f86
2020-05-13 18:51:19.725  INFO 12848 --- [           main] org.apache.zookeeper.ClientCnxnSocket    : jute.maxbuffer value is 4194304 Bytes
2020-05-13 18:51:19.733  INFO 12848 --- [168.8.128:2181)] org.apache.zookeeper.ClientCnxn          : Opening socket connection to server 192.168.8.128/192.168.8.128:2181. Will not attempt to authenticate using SASL (unknown error)
2020-05-13 18:51:19.736  INFO 12848 --- [           main] o.a.c.f.imps.CuratorFrameworkImpl        : Default schema
2020-05-13 18:51:21.743  WARN 12848 --- [168.8.128:2181)] org.apache.zookeeper.ClientCnxn          : Session 0x0 for server null, unexpected error, closing socket connection and attempting reconnect
java.net.ConnectException: Connection refused: no further information
 at java.base/sun.nio.ch.Net.pollConnect(Native Method) ~[na:na]
 at java.base/sun.nio.ch.Net.pollConnectNow(Net.java:579) ~[na:na]
 at java.base/sun.nio.ch.SocketChannelImpl.finishConnect(SocketChannelImpl.java:820) ~[na:na]
 at org.apache.zookeeper.ClientCnxnSocketNIO.doTransport(ClientCnxnSocketNIO.java:357) ~[zookeeper-3.5.3-beta.jar:3.5.3-beta-8ce24f9e675cbefffb8f21a47e06b42864475a60]
 at org.apache.zookeeper.ClientCnxn$SendThread.run(ClientCnxn.java:1214) ~[zookeeper-3.5.3-beta.jar:3.5.3-beta-8ce24f9e675cbefffb8f21a47e06b42864475a60]
2020-05-13 18:51:22.742  INFO 12848 --- [           main] ConditionEvaluationReportLoggingListener :
Error starting ApplicationContext. To display the conditions report re-run your application with 'debug' enabled.
2020-05-13 18:51:22.748 ERROR 12848 --- [           main] o.s.boot.SpringApplication               : Application run failed
java.lang.IllegalStateException: zookeeper not connected
 at org.apache.dubbo.remoting.zookeeper.curator.CuratorZookeeperClient.<init>(CuratorZookeeperClient.java:83) ~[dubbo-2.7.5.jar:2.7.5]
 at org.apache.dubbo.remoting.zookeeper.curator.CuratorZookeeperTransporter.createZookeeperClient(CuratorZookeeperTransporter.java:26) ~[dubbo-2.7.5.jar:2.7.5]
 at org.apache.dubbo.remoting.zookeeper.support.AbstractZookeeperTransporter.connect(AbstractZookeeperTransporter.java:68) ~[dubbo-2.7.5.jar:2.7.5]
 at org.apache.dubbo.remoting.zookeeper.ZookeeperTransporter$Adaptive.connect(ZookeeperTransporter$Adaptive.java) ~[dubbo-2.7.5.jar:2.7.5]
 at org.apache.dubbo.configcenter.support.zookeeper.ZookeeperDynamicConfiguration.<init>(ZookeeperDynamicConfiguration.java:70) ~[dubbo-2.7.5.jar:2.7.5]
 at org.apache.dubbo.configcenter.support.zookeeper.ZookeeperDynamicConfigurationFactory.createDynamicConfiguration(ZookeeperDynamicConfigurationFactory.java:37) ~[dubbo-2.7.5.jar:2.7.5]
 at org.apache.dubbo.common.config.configcenter.AbstractDynamicConfigurationFactory.lambda$getDynamicConfiguration$0(AbstractDynamicConfigurationFactory.java:39) ~[dubbo-2.7.5.jar:2.7.5]
 at java.base/java.util.concurrent.ConcurrentHashMap.computeIfAbsent(ConcurrentHashMap.java:1705) ~[na:na]
 at org.apache.dubbo.common.config.configcenter.AbstractDynamicConfigurationFactory.getDynamicConfiguration(AbstractDynamicConfigurationFactory.java:39) ~[dubbo-2.7.5.jar:2.7.5]
 at org.apache.dubbo.common.config.configcenter.DynamicConfiguration.getDynamicConfiguration(DynamicConfiguration.java:223) ~[dubbo-2.7.5.jar:2.7.5]
 at org.apache.dubbo.config.bootstrap.DubboBootstrap.prepareEnvironment(DubboBootstrap.java:815) ~[dubbo-2.7.5.jar:2.7.5]
 at org.apache.dubbo.config.bootstrap.DubboBootstrap.startConfigCenter(DubboBootstrap.java:560) ~[dubbo-2.7.5.jar:2.7.5]
 at org.apache.dubbo.config.bootstrap.DubboBootstrap.useRegistryAsConfigCenterIfNecessary(DubboBootstrap.java:624) ~[dubbo-2.7.5.jar:2.7.5]
 at org.apache.dubbo.config.bootstrap.DubboBootstrap.initialize(DubboBootstrap.java:508) ~[dubbo-2.7.5.jar:2.7.5]
 at org.apache.dubbo.config.bootstrap.DubboBootstrap.start(DubboBootstrap.java:698) ~[dubbo-2.7.5.jar:2.7.5]
 at org.apache.dubbo.config.spring.context.DubboBootstrapApplicationListener.onContextRefreshedEvent(DubboBootstrapApplicationListener.java:52) ~[dubbo-2.7.5.jar:2.7.5]
 at org.apache.dubbo.config.spring.context.DubboBootstrapApplicationListener.onApplicationContextEvent(DubboBootstrapApplicationListener.java:45) ~[dubbo-2.7.5.jar:2.7.5]
 at org.apache.dubbo.config.spring.context.OneTimeExecutionApplicationContextEventListener.onApplicationEvent(OneTimeExecutionApplicationContextEventListener.java:40) ~[dubbo-2.7.5.jar:2.7.5]
 at org.springframework.context.event.SimpleApplicationEventMulticaster.doInvokeListener(SimpleApplicationEventMulticaster.java:172) ~[spring-context-5.2.4.RELEASE.jar:5.2.4.RELEASE]
 at org.springframework.context.event.SimpleApplicationEventMulticaster.invokeListener(SimpleApplicationEventMulticaster.java:165) ~[spring-context-5.2.4.RELEASE.jar:5.2.4.RELEASE]
 at org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:139) ~[spring-context-5.2.4.RELEASE.jar:5.2.4.RELEASE]
 at org.springframework.context.support.AbstractApplicationContext.publishEvent(AbstractApplicationContext.java:403) ~[spring-context-5.2.4.RELEASE.jar:5.2.4.RELEASE]
 at org.springframework.context.support.AbstractApplicationContext.publishEvent(AbstractApplicationContext.java:360) ~[spring-context-5.2.4.RELEASE.jar:5.2.4.RELEASE]
 at org.springframework.context.support.AbstractApplicationContext.finishRefresh(AbstractApplicationContext.java:897) ~[spring-context-5.2.4.RELEASE.jar:5.2.4.RELEASE]
 at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:553) ~[spring-context-5.2.4.RELEASE.jar:5.2.4.RELEASE]
 at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:747) ~[spring-boot-2.2.5.RELEASE.jar:2.2.5.RELEASE]
 at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:397) ~[spring-boot-2.2.5.RELEASE.jar:2.2.5.RELEASE]
 at org.springframework.boot.SpringApplication.run(SpringApplication.java:315) ~[spring-boot-2.2.5.RELEASE.jar:2.2.5.RELEASE]
 at org.springframework.boot.SpringApplication.run(SpringApplication.java:1226) ~[spring-boot-2.2.5.RELEASE.jar:2.2.5.RELEASE]
 at org.springframework.boot.SpringApplication.run(SpringApplication.java:1215) ~[spring-boot-2.2.5.RELEASE.jar:2.2.5.RELEASE]
 at com.ego.ProviderApplication.main(ProviderApplication.java:13) ~[classes/:na]
Caused by: java.lang.IllegalStateException: zookeeper not connected
 at org.apache.dubbo.remoting.zookeeper.curator.CuratorZookeeperClient.<init>(CuratorZookeeperClient.java:80) ~[dubbo-2.7.5.jar:2.7.5]
 ... 30 common frames omitted
2020-05-13 18:51:22.750  INFO 12848 --- [           main] .b.c.e.AwaitingNonWebApplicationListener :  [Dubbo] Current Spring Boot Application is about to shutdown...
2020-05-13 18:51:22.751  WARN 12848 --- [           main] s.c.a.AnnotationConfigApplicationContext : Exception thrown from ApplicationListener handling ContextClosedEvent
java.lang.NullPointerException: null
 at org.apache.dubbo.config.bootstrap.DubboBootstrap.unexportMetadataService(DubboBootstrap.java:857) ~[dubbo-2.7.5.jar:2.7.5]
 at org.apache.dubbo.config.bootstrap.DubboBootstrap.destroy(DubboBootstrap.java:996) ~[dubbo-2.7.5.jar:2.7.5]
 at org.apache.dubbo.config.bootstrap.DubboBootstrap.stop(DubboBootstrap.java:776) ~[dubbo-2.7.5.jar:2.7.5]
 at org.apache.dubbo.config.spring.context.DubboBootstrapApplicationListener.onContextClosedEvent(DubboBootstrapApplicationListener.java:56) ~[dubbo-2.7.5.jar:2.7.5]
 at org.apache.dubbo.config.spring.context.DubboBootstrapApplicationListener.onApplicationContextEvent(DubboBootstrapApplicationListener.java:47) ~[dubbo-2.7.5.jar:2.7.5]
 at org.apache.dubbo.config.spring.context.OneTimeExecutionApplicationContextEventListener.onApplicationEvent(OneTimeExecutionApplicationContextEventListener.java:40) ~[dubbo-2.7.5.jar:2.7.5]
 at org.springframework.context.event.SimpleApplicationEventMulticaster.doInvokeListener(SimpleApplicationEventMulticaster.java:172) ~[spring-context-5.2.4.RELEASE.jar:5.2.4.RELEASE]
 at org.springframework.context.event.SimpleApplicationEventMulticaster.invokeListener(SimpleApplicationEventMulticaster.java:165) ~[spring-context-5.2.4.RELEASE.jar:5.2.4.RELEASE]
 at org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:139) ~[spring-context-5.2.4.RELEASE.jar:5.2.4.RELEASE]
 at org.springframework.context.support.AbstractApplicationContext.publishEvent(AbstractApplicationContext.java:403) ~[spring-context-5.2.4.RELEASE.jar:5.2.4.RELEASE]
 at org.springframework.context.support.AbstractApplicationContext.publishEvent(AbstractApplicationContext.java:360) ~[spring-context-5.2.4.RELEASE.jar:5.2.4.RELEASE]
 at org.springframework.context.support.AbstractApplicationContext.doClose(AbstractApplicationContext.java:1012) ~[spring-context-5.2.4.RELEASE.jar:5.2.4.RELEASE]
 at org.springframework.context.support.AbstractApplicationContext.close(AbstractApplicationContext.java:978) ~[spring-context-5.2.4.RELEASE.jar:5.2.4.RELEASE]
 at org.springframework.boot.SpringApplication.handleRunFailure(SpringApplication.java:803) ~[spring-boot-2.2.5.RELEASE.jar:2.2.5.RELEASE]
 at org.springframework.boot.SpringApplication.run(SpringApplication.java:325) ~[spring-boot-2.2.5.RELEASE.jar:2.2.5.RELEASE]
 at org.springframework.boot.SpringApplication.run(SpringApplication.java:1226) ~[spring-boot-2.2.5.RELEASE.jar:2.2.5.RELEASE]
 at org.springframework.boot.SpringApplication.run(SpringApplication.java:1215) ~[spring-boot-2.2.5.RELEASE.jar:2.2.5.RELEASE]
 at com.ego.ProviderApplication.main(ProviderApplication.java:13) ~[classes/:na]
2020-05-13 18:51:22.755  INFO 12848 --- [           main] com.alibaba.druid.pool.DruidDataSource   : {dataSource-1} closed
2020-05-13 18:51:22.755  INFO 12848 --- [           main] f.a.ReferenceAnnotationBeanPostProcessor : class org.apache.dubbo.config.spring.beans.factory.annotation.ReferenceAnnotationBeanPostProcessor was destroying!
Process finished with exit code 1


JAVA 全系列/第十八阶段:亿级高并发电商项目_架构/编码(旧)/电商:基于json数据格式完成商品规格参数模板管理 32676楼

老师 你好 ,目前工作中,所有api 接口用的都是post方法,retrieveapiview 我想写一个post 方法 里面调用get 方法 ,好像不行。麻烦老师看下 有什么办法满足这样的需求

"""

from django.http import JsonResponse, HttpResponse
from django.shortcuts import render

# Create your views here.
from django.views.decorators.csrf import csrf_exempt
from rest_framework.parsers import JSONParser

from res_demo.models import Student
from res_demo.serializers import StudentSerializer
from rest_framework import mixins
from rest_framework import generics


# @csrf_exempt
# def students(request):
#     if request.method=="GET":
#         student_li=Student.objects.all()
#         serializre = StudentSerializer(student_li,many=True)
#         return JsonResponse(serializre.data,safe=False)
#
#     elif request.method=="POST":
#         data = JSONParser().parse(request)
#         serializre=StudentSerializer(data=data)
#         if serializre.is_valid():
#             serializre.save()
#             return JsonResponse(serializre.data,status=201)
#         return JsonResponse(serializre.errors,status=400)
#
# @csrf_exempt
# def student_detail(request, pk):
#     try:
#         student = Student.objects.get(pk=pk)
#     except Student.DoesNotExist:
#         return HttpResponse(status=404)
#
#     if request.method == 'GET':
#         serializer = StudentSerializer(student)
#         return JsonResponse(serializer.data)
#
#     elif request.method == 'PUT':
#         data = JSONParser().parse(request)
#         serializer = StudentSerializer(student, data=data)
#         if serializer.is_valid():
#             serializer.save()
#             return JsonResponse(serializer.data)
#         return JsonResponse(serializer.errors, status=400)
#
#     elif request.method == 'DELETE':
#         student.delete()
#         return HttpResponse(status=204)


class StudentsView(generics.ListAPIView):
    """
    查询学生列表
    """

    queryset = Student.objects.all()
    serializer_class = StudentSerializer



    def post(self, request, *args, **kwargs):
        print(type(request.data))
        json_data:dict=request.data
        print(json_data)

        id= json_data.get("id")


        self.queryset=StudentsView.queryset.filter(id=id).all()

        return self.get(request,*args,**kwargs)

class StudentDetail(generics.RetrieveAPIView):
    queryset = Student.objects.all()
    serializer_class = StudentSerializer


    def post(self,request,*args,**kwargs):
        print(self.lookup_field)
        print(self.lookup_url_kwarg)
        self.queryset = StudentsView.queryset.filter(id=5).all()
        return  self.get(request,*args,**kwargs)

image.png

Python 全系列/第十二阶段:Python_Django3框架/Django高级 32677楼
WEB前端全系列/第二阶段:JavaScript编程模块/浏览器模型(BOM) 32680楼
JAVA 全系列/第二阶段:JAVA 基础深化和提高/反射技术(旧) 32681楼
JAVA 全系列/第二阶段:JAVA 基础深化和提高/容器(旧) 32685楼

课程分类

百战程序员微信公众号

百战程序员微信小程序

©2014-2025百战汇智(北京)科技有限公司 All Rights Reserved 北京亦庄经济开发区科创十四街 赛蒂国际工业园
网站维护:百战汇智(北京)科技有限公司
京公网安备 11011402011233号    京ICP备18060230号-3    营业执照    经营许可证:京B2-20212637