在配置spring配置文件时各种报错,解决办法

好久没在这上面记东西了,把以前遇到的问题整理一下贴出来,希望给同样遇到问题的朋友们一点帮助


1、配置sping配置文件时,一直报错,原来是在头部没有声明context前缀:



2、进行配置时,产生如下错误:Error occured processing XML 'org/springframework/transaction/interceptor/TransactionInterceptor'.可以引入aopalliance-1.0.jar这个jar包来解决,引入之后,clean一下项目,错误就消失啦!



3、配置时报如下的错误,导入mybatis-spring-1.1.1-SNAPSHOT.jar这个jar包可以解决



4、配置时报如下的错误,导入mybatis-3.1.1-SNAPSHOT.jar包可以解决此问题。



5、关于classpath:<util:properties id="xxx" location="classpath:xxxxx.properties"

classpath表明,将从类路径上查找并装载xxx属性文件

这里的类路径是指在tomcat的webapp路径下(项目发布的路径,如:C:\Program Files\Apache Software Foundation\Tomcat 7.0\webapps\OSS\WEB-INF\classes),将在classes路径下查找并装载XXX.properties属性文件
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
可能是SSL证书问题导致的。你可以尝试在Swagger的配置文件中添加如下配置,忽略SSL证书的验证: ```java @Bean public Docket api() { return new Docket(DocumentationType.SWAGGER_2) .protocols(new HashSet<>(Arrays.asList("https", "http"))) .apiInfo(apiInfo()) .select() .apis(RequestHandlerSelectors.any()) .paths(PathSelectors.any()) .build() .securitySchemes(Arrays.asList(apiKey())) .securityContexts(Arrays.asList(securityContext())); } private ApiKey apiKey() { return new ApiKey("JWT", AUTHORIZATION_HEADER, "header"); } private SecurityContext securityContext() { return SecurityContext.builder() .securityReferences(defaultAuth()) .forPaths(PathSelectors.any()) .build(); } List<SecurityReference> defaultAuth() { AuthorizationScope authorizationScope = new AuthorizationScope("global", "accessEverything"); AuthorizationScope[] authorizationScopes = new AuthorizationScope[1]; authorizationScopes[0] = authorizationScope; return Arrays.asList(new SecurityReference("JWT", authorizationScopes)); } private ApiInfo apiInfo() { return new ApiInfoBuilder() .title("API接口文档") .description("SpringBoot整合Swagger,详细信息......") .termsOfServiceUrl("http://localhost:8080/") .contact("联系人") .version("1.0") .build(); } @Bean public RestTemplate restTemplate() throws Exception { TrustStrategy acceptingTrustStrategy = (X509Certificate[] chain, String authType) -> true; SSLContext sslContext = SSLContexts.custom().loadTrustMaterial(null, acceptingTrustStrategy).build(); SSLConnectionSocketFactory csf = new SSLConnectionSocketFactory(sslContext); CloseableHttpClient httpClient = HttpClients.custom().setSSLSocketFactory(csf).build(); HttpComponentsClientHttpRequestFactory requestFactory = new HttpComponentsClientHttpRequestFactory(); requestFactory.setHttpClient(httpClient); RestTemplate restTemplate = new RestTemplate(requestFactory); return restTemplate; } ``` 其中,`restTemplate()` 方法中的代码是忽略SSL证书的验证。如果你不需要使用RestTemplate,可以不需要这个方法。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值