我正在开发 Spring Boot 应用程序,我想 jackson-databind从2.9.10.2升级到2.10.2。以下是我的 pom.xml 的片段以及升级依赖项后遇到的错误:
pom.xml:
<dependency>
<groupId>com.fasterxml.jackson.dataformat</groupId>
<artifactId>jackson-dataformat-xml</artifactId>
<version>2.9.9</version>
<exclusions>
<exclusion>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
<version>2.10.2</version>
</dependency>
Run Code Online (Sandbox Code Playgroud)
启动 ApplicationContext 时出错。要显示条件报告,请在启用“调试”的情况下重新运行应用程序。13-03-2020 17:38:52.660 ||错误|osboot.SpringApplication:821 |应用程序运行失败org.springframework.beans.factory.BeanCreationException:创建类路径资源中定义的名为“requestMappingHandlerAdapter”的bean时出错[org/springframework /boot/autoconfigure/web/servlet/WebMvcAutoConfiguration$EnableWebMvcConfiguration.class]:通过工厂方法实例化 Bean 失败;嵌套异常是 org.springframework.beans.BeanInstantiationException:无法实例化 [org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter]:工厂方法“requestMappingHandlerAdapter”抛出异常;嵌套异常是org.springframework.beans.factory.BeanCreationException:创建名称为“org.springframework.boot.autoconfigure.http.HttpMessageConvertersAutoConfiguration”的bean时出错:通过构造函数实例化Bean失败;嵌套异常是 org.springframework.beans.BeanInstantiationException:无法实例化 [org.springframework.boot.autoconfigure.http.HttpMessageConvertersAutoConfiguration$$EnhancerBySpringCGLIB$$1f3fa4d]:构造函数抛出异常;嵌套异常是org.springframework.beans.factory.UnsatisfiedDependencyException:创建在类路径资源[org/springframework/boot/autoconfigure/http/JacksonHttpMessageConvertersConfiguration$MappingJackson2HttpMessageConverterConfiguration.class]中定义的名为“mappingJackson2HttpMessageConverter”的bean时出错:通过方法“表达的依赖关系不满足” mappingJackson2HttpMessageConverter'参数0;嵌套异常是org.springframework.beans.factory.BeanCreationException:创建类路径资源中定义的名为“jacksonObjectMapper”的bean时出错[org/springframework/boot/autoconfigure/jackson/JacksonAutoConfiguration$JacksonObjectMapperConfiguration.class]:合并bean的后处理定义失败;嵌套异常是 java.lang.IllegalStateException:无法从 org.springframework.beans.factory.support.ConstructorResolver 的 ClassLoader [sun.misc.Launcher$AppClassLoader@18b4aac2] 内省类 [com.fasterxml.jackson.databind.ObjectMapper]。实例化(ConstructorResolver.java:627)在org.springframework.beans.factory.support.ConstructorResolver.instantiateUsingFactoryMethod(ConstructorResolver.java:607)在org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateUsingFactoryMethod(AbstractAutowireCapableBeanFactory.java:132) 1)在 org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1160) 在 org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java: 555) 在 org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:515) 在 org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:320) 在 org. springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222)在org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:318)在org.springframework.beans.factory.support。 AbstractBeanFactory.getBean(AbstractBeanFactory.java:199)在org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:845)在org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:877)在 org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:549) 在 org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:140) 在 org.springframework.boot.SpringApplication .refresh(SpringApplication.java:742) 在 org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:389) 在 org.springframework.boot.SpringApplication.run(SpringApplication.java:311) 在 org.springframework.boot。 SpringApplication.run(SpringApplication.java:1213)在org.springframework.boot.SpringApplication.run(SpringApplication.java:1202)在com.finicity.accountowner.AccountOwnerApplication.main(AccountOwnerApplication.java:29)引起:org.springframework .beans.BeanInstantiationException:无法实例化[org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter]:工厂方法“requestMappingHandlerAdapter”抛出异常;嵌套异常是org.springframework.beans.factory.BeanCreationException:创建名称为“org.springframework.boot.autoconfigure.http.HttpMessageConvertersAutoConfiguration”的bean时出错:通过构造函数实例化Bean失败;嵌套异常是 org.springframework.beans.BeanInstantiationException:无法实例化 [org.springframework.boot.autoconfigure.http.HttpMessageConvertersAutoConfiguration$$EnhancerBySpringCGLIB$$1f3fa4d]:构造函数抛出异常;嵌套异常是org.springframework.beans.factory.UnsatisfiedDependencyException:创建在类路径资源[org/springframework/boot/autoconfigure/http/JacksonHttpMessageConvertersConfiguration$MappingJackson2HttpMessageConverterConfiguration.class]中定义的名为“mappingJackson2HttpMessageConverter”的bean时出错:通过方法“表达的依赖关系不满足” …
我创建了一个 github 存储库https://github.com/Nisarg04/microservices-config-repo.git,我希望将其视为配置存储库。另外,我有一个 Spring Cloud 服务器,它从本地存储库中选择属性(根据当前配置)。我希望从 github 存储库中选取它。
application.properties看起来像这样:
spring.application.name=spring-cloud-config-server
server.port=8888
#spring.cloud.config.server.git.uri=file:///C:/Users/admin/git/git-localconfig-repo
spring.cloud.config.server.git.uri=https://github.com/Nisarg04/microservices-config-repo.git
management.security.enabled=false
Run Code Online (Sandbox Code Playgroud)
当我指向 时git-localconfig-repo,它工作完美。但是,当我指向我的存储库时,它给出了错误:Cannot clone or checkout repository: https://github.com/Nisarg04/microservices-config-repo.git
我该如何解决这个问题?
编辑:也尝试过
spring.cloud.config.server.git.username=nisarg04
spring.cloud.config.server.git.password=mypassword
,但即使这样也有帮助
根据要求,我添加了以下服务器类:
@SpringBootApplication
@EnableConfigServer
public class SpringCloudConfigServerApplication {
public static void main(String[] args) {
SpringApplication.run(SpringCloudConfigServerApplication.class, args);
}
}
Run Code Online (Sandbox Code Playgroud) List<String> strList1 = Arrays.asList("aaa", "bbb", "ccc");
List<String> strList2 = Arrays.asList("ddd", "eee", "fff");
List<List<String>> list = Arrays.asList(strList1,strList2);
int noOfElements = (int) list.stream().flatMap(i->i.stream()).count();
System.out.println(noOfElements);
Run Code Online (Sandbox Code Playgroud)
我想计算个人数量Strings(如上面的代码片段所示).在展平列表后我能够这样做,但我想在不使用的情况下做同样的事情flatMap().必须有一些方法来计算.提前致谢.
我有一个用例,其中有两个布尔属性,我需要根据它们导出实例变量的值。下面是代码片段:
@Value("${propFlag1:false}")
private Boolean flag1;
@Value("${propFlag2:false}")
private Boolean flag2;
@Value("${propFlag2:false && propFlag1:false}")
private Boolean flag3;
@Value("${propFlag1:false && propFlag2:false}")
private Boolean flag4;
Run Code Online (Sandbox Code Playgroud)
这里,propFlag1和propFlag2是属性文件中的标志,分别具有值true和false。为和
正确注入值,但对于和,注入的值分别为和,而不是两者。
所以,当我尝试使用flag1flag2flag3flag4falsetruefalse&&, it is not ANDing two values, rather it is injecting the value of first variable itself. What am I doing wrong here?
PS:我是 SpEL 的新手