springmvc4 spring4 swagger配置问题

来源:互联网 发布:java 书籍推荐 编辑:程序博客网 时间:2024/05/19 17:08

问题1:

HTTP Status 500 - Request processing failed; nested exception is java.util.NoSuchElementException

之前配置好的swagger访问类似http://192.168.1.100:8999/leyutech-framework-huang/api-docs,(项目名称自行更改)让我很费解,刚开始以为是spring版本问题,做了很多的调整,最后发现是注入:
<!-- Swagger配置 -->
<bean id="springSwaggerConfig" class="com.mangofactory.swagger.configuration.SpringSwaggerConfig" />

的位置问题,注入该方法一定要放在你扫描对应的接口之前,否则就会出现这种问题,还有,使用了不同的sping版本的,xml的头

问题2:

出现接口重复问题,调整发现是spring的扫描问题,我最后将swagger的相关东西抽出来,单独扫描,问题解决。将下面配置生成xml引入spring主配置文件。

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:context="http://www.springframework.org/schema/context"
xmlns:mvc="http://www.springframework.org/schema/mvc" xmlns:tx="http://www.springframework.org/schema/tx"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-4.1.xsd
http://www.springframework.org/schema/tx 
http://www.springframework.org/schema/tx/spring-tx-4.1.xsd
  http://www.springframework.org/schema/context
  http://www.springframework.org/schema/context/spring-context-4.1.xsd">
<!-- Swagger配置 -->
<bean id="springSwaggerConfig"
class="com.mangofactory.swagger.configuration.SpringSwaggerConfig" />
<bean class="cn.leyutech.gurunwanfeng.remote.LeyuSwaggerConfig" />
<context:component-scan
base-package="cn.leyutech.gurunwanfeng.remote">
</context:component-scan>
</beans>   

0 0
原创粉丝点击