小编Fat*_*tih的帖子

拒绝应用样式,因为其 MIME 类型('application/json')不是受支持的样式表 MIME 类型,并且启用了严格的 MIME 检查

我添加swagger-ui到我的 spring-boot 服务应用程序中,在访问链接时遇到了一些类似的错误/swagger-ui/

浏览器控制台出错,请查看图片(点击此链接)

我在招摇中的参考来自这里:

https://www.baeldung.com/swagger-2-documentation-for-spring-rest-api

这是我的配置示例代码:

@Configuration
public class WebConfiguration implements WebMvcConfigurer {

    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        registry.addInterceptor(new LoggerInterceptor());
    }

    public void addResourceHandlers(ResourceHandlerRegistry registry) {
        registry.addResourceHandler("swagger-ui.html").addResourceLocations("classpath:/META-INF/resources/");
        registry.addResourceHandler("/webjars/**").addResourceLocations("classpath:/META-INF/resources/webjars/");
    }

}
Run Code Online (Sandbox Code Playgroud)

我尝试排除这部分:


    public void addResourceHandlers(ResourceHandlerRegistry registry) {
        registry.addResourceHandler("swagger-ui.html").addResourceLocations("classpath:/META-INF/resources/");
        registry.addResourceHandler("/webjars/**").addResourceLocations("classpath:/META-INF/resources/webjars/");
    }
Run Code Online (Sandbox Code Playgroud)

仍然没有决心。希望有人可以帮忙。谢谢。

swagger-ui spring-boot springfox-boot-starter

4
推荐指数
1
解决办法
4173
查看次数

如何在 Java 中使用 Gson @SerializedName 序列化嵌套对象?

我有twitter数据。这些数据中有一些nested对象。我想将这些字段收集到Java. 我正在使用@SerializedName注释将一些嵌套字段导入到我的 java 对象中。

我的示例 json 如下所示:

{
  "created_at": "Sat Jun 15 19:21:29 +0000 2019",
  "text": "RT @BuzzTechy: [BEST] Udemy Course - Create a Python Powered Chatbot in Under 60 Minutes  \n\nhttps:\/\/t.co\/jMIW38FmmZ \n\n#AI #Python #Chatbot\u2026",
  "source": "\u003ca href=\"https:\/\/allentowngroup.com\" rel=\"nofollow\"\u003ebobbidigi\u003c\/a\u003e",
  "truncated": false,
  "in_reply_to_screen_name": "asdsf"
  "user": {
    "id": 1724601306,
    "name": "Rob's Coding News In The Hood"
  }
}
Run Code Online (Sandbox Code Playgroud)

和我的java对象:

public class TweetEntity implements Serializable {

private static long serialVersionUID = 1L;

@SerializedName("created_at")
private Date …
Run Code Online (Sandbox Code Playgroud)

java serialization json gson

3
推荐指数
1
解决办法
5872
查看次数