zoukankan      html  css  js  c++  java
  • Java 学习笔记(四)

    restful API设计时,注意设计的幂等性。

     原理参考: https://www.cnblogs.com/javalyy/p/8882144.html 

    19. 运行错误:

    org.springframework.beans.factory.BeanCreationException: 
    Error creating bean with name 'springSecurityFilterChain' defined in class path resource [org/springframework/security/config/annotation/web/configuration/WebSecurityConfiguration.class]: Bean instantiation via factory method failed; 
    nested exception is org.springframework.beans.BeanInstantiationException: 
    Failed to instantiate [javax.servlet.Filter]: Factory method 'springSecurityFilterChain' threw exception; 
    nested exception is java.lang.NoClassDefFoundError: javax/xml/bind/JAXBException

    原因如下:

    stackoverflow.com/questions/43574426/how-to-resolve-java-lang-noclassdeffounderror-javax-xml-bind-jaxbexception-in-j

    可以按帖子里说的,只导入对应的包

    <!-- API, java.xml.bind module -->
    <dependency>
        <groupId>jakarta.xml.bind</groupId>
        <artifactId>jakarta.xml.bind-api</artifactId>
        <version>2.3.2</version>
    </dependency>
    
    <!-- Runtime, com.sun.xml.bind module -->
    <dependency>
        <groupId>org.glassfish.jaxb</groupId>
        <artifactId>jaxb-runtime</artifactId>
        <version>2.3.2</version>
    </dependency>

    这些包也存在于这些集合包里:

            <dependency>
                <groupId>org.springframework.security.oauth.boot</groupId>
                <artifactId>spring-security-oauth2-autoconfigure</artifactId>
                <version>2.2.1.RELEASE</version>
            </dependency>

    其中的版本号自行更新。

    20.  com.netflix.discovery.shared.transport.TransportException: Cannot execute request on any known server

    这里有一个总结: https://blog.csdn.net/u013829202/article/details/84649062

    不过对我还是不适用。

    然后我参照了官方的例子中的complete: https://spring.io/guides/gs/service-registration-and-discovery/   

    然后删除client工程里application.yml里的关于eureka的配置:

    #eureka:
    #  client:
    #    service-url:
    #      defaultZone: http://localhost:8761/

    然后我自己的client就可以注册到官方例子中的euraeka server里了。

    21. 明明不用配置eureka,就可以自动注册到服务器里的,为什么我的就是不行呢?

    答案: 不要引用

            <dependency>
                <groupId>org.springframework.cloud</groupId>
                <artifactId>spring-cloud-netflix-eureka-client</artifactId>
            </dependency>

    而要引用:

            <dependency>
                <groupId>org.springframework.cloud</groupId>
                <artifactId>spring-cloud-starter-netflix-eureka-client</artifactId>
            </dependency>

    注意两者有个starter的差别。

    eureka
  • 相关阅读:
    自定义 mapper
    solr 服务搭建
    jedis 连接redis
    jedis 整合 Spring
    Redis 安装
    HttpClient 工具类
    springMvc 中返回字符串 乱码解决
    linux常用命令解析
    压缩jar包
    控制反转
  • 原文地址:https://www.cnblogs.com/crazyghostvon/p/Javalearn4.html
Copyright © 2011-2022 走看看