小编sae*_*edj的帖子

解决 gradle 中的 findBugs 问题

概述:

我正在尝试在我的项目中升级 Java 和 Gradle 版本,如下所示:

  • java从8到11
  • 从 5 级到 6 级

我的项目在旧版本上运行没有问题,但是在 Java 11 和 Gradle 6 上运行时,它会抱怨 fireBugs 插件并引发以下异常:

 > Plugin with id 'findbugs' not found.
Run Code Online (Sandbox Code Playgroud)

gradle 文件的片段:

buildscript {
    ext {
        SampleProjectVersion = '1.3.4'
    }
    repositories {
        mavenLocal()
        maven {
            url1
        }
    }
    dependencies {
        classpath(sample lib 1)
        classpath(sample lib 2)
    }

apply plugin: 'findbugs'

...
Run Code Online (Sandbox Code Playgroud)

如果您能与我分享您的想法,我将不胜感激,因为我找不到任何合适的解决方案。

java findbugs gradle

14
推荐指数
1
解决办法
2万
查看次数

如何注释OpenAPI(Swagger)2.0中不推荐使用的字段?

我有以下架构定义:

swagger: '2.0'
...
definitions:
  Service:
    type: object
    properties:
      serviceId:
        type: string
        description: Device or service identification number
        example: 1111111111      
      location:
        type: string
        description: Location of the service
        example: '400 Street name, City State postcode, Country'
Run Code Online (Sandbox Code Playgroud)

我想对location已弃用的字段进行注释。有没有办法做到这一点?

swagger swagger-2.0 openapi

13
推荐指数
2
解决办法
8714
查看次数

无法在IntelliJ Idea中启动spring-boot应用程序

概观

我可以使用spring-boot的maven插件运行应用程序,但不能使用IDE运行它.以下几行详细介绍了我的程序.

应用程序类如下:

package com.blss.retailServices.dataExportRouter;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.boot.autoconfigure.velocity.VelocityAutoConfiguration;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;

@Configuration
@ComponentScan
@EnableAutoConfiguration(exclude = { VelocityAutoConfiguration.class })
public class DataExportRouterApplication {
    public static void main(String[] args) throws Exception {
        SpringApplication.run(DataExportRouterApplication.class, args);
    }
}
Run Code Online (Sandbox Code Playgroud)

异常堆栈跟踪如下:

org.springframework.context.ApplicationContextException: Unable to start embedded container; nested exception is org.springframework.context.ApplicationContextException: Unable to start EmbeddedWebApplicationContext due to missing EmbeddedServletContainerFactory bean.
    at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.onRefresh(EmbeddedWebApplicationContext.java:133) ~[spring-boot-1.3.3.RELEASE.jar:1.3.3.RELEASE]
    at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:532) ~[spring-context-4.2.5.RELEASE.jar:4.2.5.RELEASE]
    at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.refresh(EmbeddedWebApplicationContext.java:118) ~[spring-boot-1.3.3.RELEASE.jar:1.3.3.RELEASE]
    at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:766) [spring-boot-1.3.3.RELEASE.jar:1.3.3.RELEASE]
    at org.springframework.boot.SpringApplication.createAndRefreshContext(SpringApplication.java:361) [spring-boot-1.3.3.RELEASE.jar:1.3.3.RELEASE]
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:307) [spring-boot-1.3.3.RELEASE.jar:1.3.3.RELEASE]
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:1191) [spring-boot-1.3.3.RELEASE.jar:1.3.3.RELEASE]
    at …
Run Code Online (Sandbox Code Playgroud)

java exception intellij-idea spring-boot

11
推荐指数
1
解决办法
8355
查看次数

如何在 Gradle 4.7 中设置 Spring Boot 活动配置文件

总体而言:
我正在尝试为特定的 spring 配置文件运行 gradle 构建任务,但在通过以下测试时出错:

au.com.mnpd.security.JwtTokenUtilTest > generateToken_succeeds FAILED
java.lang.IllegalStateException
    Caused by: org.springframework.beans.factory.UnsatisfiedDependencyException
        Caused by: org.springframework.beans.factory.UnsatisfiedDependencyException
            Caused by: org.springframework.beans.factory.UnsatisfiedDependencyException
                Caused by: org.springframework.beans.factory.BeanCreationException
                    Caused by: java.lang.IllegalArgumentException
Run Code Online (Sandbox Code Playgroud)

该测试使用了 spring开发配置文件中的一些属性(位于 application-development.yaml 中)。但是我找不到任何方法将活动配置文件传递给 gradle build 命令。我尝试了以下但同样的问题:

- gradlew -Dspring.profiles.active=development build

- gradlew -Pdevelopment build
Run Code Online (Sandbox Code Playgroud)

问题:
是否有将活动配置文件传递给 gradle (v 4.7)构建任务,例如适用于bootRun任务的内容,如下所示:

bootRun {
        bootRun.systemProperty 'spring.profiles.active', 'development'
}
Run Code Online (Sandbox Code Playgroud)

注意:我为构建尝试了相同的方法,但构建任务不存在build.systemProperty方法。

由于我是 gradle 新手,如果您能与我分享您的真正解决方案,我将不胜感激。

java profile gradle spring-boot

9
推荐指数
3
解决办法
2万
查看次数

Windows 上的 GIT 问题(文件名或扩展名太长)

概述:

刚刚在我的 Windows 7 平台上安装了 GIT 版本 2.20.1-64 位。Git 在 GIT Bash 上运行良好;但是,Windows CMD 或 Powershell 上的任何 git 命令都会引发文件名或扩展名太长错误。

细节:

  • GIT版本:2.20.1-64位
  • 平台:Windows 7

故障排除工作:

我尝试根据 Git for Windows 中的 Filename too long将 longpaths 属性切换为 true 。我还通过谷歌搜索找到其他解决方案,但都推荐了更新 git 配置的相同方法。

  • GIT 配置文件更新为git config --system core.longpaths true 在此输入图像描述

问题:

通过 Windows CMD 或 IntelliJ Idea 等第三方应用程序执行的任何 Git 命令都会引发以下错误:

  • 命令: 在此输入图像描述

  • 智能: 在此输入图像描述

请告诉我你真正的解决方案。

windows git

6
推荐指数
1
解决办法
8683
查看次数

如何为独立的Wiremock启用HTTPS

概述:

我使用独立的Wiremock 2.1.11,并执行以下操作为请求启用HTTPS URL,但无济于事:

运行wiremock的命令如下:

java -jar wiremock-standalone-2.1.11.jar --port 8920 --https-port 8921 --https-keystore /home/wiremock/keystore/clientkeystore --verbose
Run Code Online (Sandbox Code Playgroud)

注意: 我可以通过http端口正确连接


现在,如果有人可以帮助我找到HTTPS连接的解决方案,我将不胜感激。

https wiremock

5
推荐指数
1
解决办法
2508
查看次数

用于使用 SOAP 网络服务的 CXF SSL 配置

概述 我将设置 SSL 配置以调用 SOAP 网络服务。

证书信息:

  • 证书文件:sureft.p12
  • 密码:sureft

CXF 配置文件 (cxf.xml):

<beans xmlns="http://www.springframework.org/schema/beans"
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
       xmlns:sec="http://cxf.apache.org/configuration/security"
       xmlns:http="http://cxf.apache.org/transports/http/configuration"
       xmlns:jaxws="http://java.sun.com/xml/ns/jaxws" xmlns:cxf="http://www.springframework.org/schema/c"
       xsi:schemaLocation="
      http://cxf.apache.org/configuration/security
      http://cxf.apache.org/schemas/configuration/security.xsd
      http://cxf.apache.org/transports/http/configuration
      http://cxf.apache.org/schemas/configuration/http-conf.xsd
      http://www.springframework.org/schema/beans
      http://www.springframework.org/schema/beans/spring-beans-2.0.xsd">

    <http:conduit name="{http://tmr.qld.gov.au/srvc/getregistrationstatus/v2_0}GetRegistrationStatusPort.http-conduit">

<http:tlsClientParameters>
            <sec:keyManagers keyPassword="sureft">
                <sec:keyStore type="pksc12" password="sureft"
                              file="keystore/sureft.p12"/>
            </sec:keyManagers>
</http:tlsClientParameters>

<http:client AutoRedirect="true" Connection="Keep-Alive"/>

    </http:conduit>
</beans>
Run Code Online (Sandbox Code Playgroud)

问题

但是,当 Web 服务调用时,它会抛出 403:

org.springframework.web.util.NestedServletException: Request processing failed; nested exception is com.sun.xml.internal.ws.client.ClientTransportException: The server sent HTTP status code 403: Forbidden 
Run Code Online (Sandbox Code Playgroud)

我查看了http://cxf.apache.org/docs/client-http-transport-including-ssl-support.html但我无法解决问题。现在,如果有人能帮我找到这个问题的解决方案,我将不胜感激。

更新级别 1:

我做了以下更改,但 403 再次引发:

. 创建信任库:

  • 从sureft.p12 导出创建名为myCert.cer 的cer 文件
  • 通过运行以下命令创建名为 myTruststore.jks 的信任库证书: …

apache ssl soap cxf p12

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

如何将属性从application.properties传递到logback配置文件

概述:

我在我的logback.xml文件中使用Sentry appender,我想将大量标签作为参数从application.properties文件传递到logback配置文件.

logback.xml文件:

<?xml version="1.0" encoding="UTF-8"?>
<configuration>
    <include resource="org/springframework/boot/logging/logback/defaults.xml"/>
    <include resource="org/springframework/boot/logging/logback/file-appender.xml"/>
    <include resource="org/springframework/boot/logging/logback/console-appender.xml"/>

    <appender name="SENTRY" class="com.getsentry.raven.logback.SentryAppender">
        <dsn>
            https://e0a61232c92f42ffa34c22914d676a8e:e64f7edc60de490eb004556d2b3fce45@sentry.io/112817
        </dsn>
        <springProfile name="dev">
            <tags>env:dev,app:${app.name},platform:aws</tags>
        </springProfile>
        <springProfile name="stage">
            <tags>env:dev</tags>
        </springProfile>
        <springProfile name="test">
            <tags>env:test</tags>
        </springProfile>

        <filter class="ch.qos.logback.classic.filter.ThresholdFilter">
            <level>ERROR</level>
        </filter>
    </appender>

    <root level="ERROR">
        <appender-ref ref="CONSOLE"/>
        <appender-ref ref="SENTRY"/>
    </root>

</configuration> 
Run Code Online (Sandbox Code Playgroud)

application.properties:

security.ignored=/**

logging.level.root = DEBUG

spring.profiles.active=dev
app.name=retailServices
Run Code Online (Sandbox Code Playgroud)

注意: application.properties中的spring.profiles.active属性映射到logback配置文件中的springProfile标记.


但问题是在logback.xml文件中找不到"app.name"属性.如果我将此属性用作系统属性,它可以工作,但我想将它从application.properties传递给配置文件.

所以任何解决方案,反馈和想法都将受到高度赞赏.

logback sentry spring-boot

4
推荐指数
2
解决办法
6533
查看次数

POST请求中的CSRF令牌无效

概述
我将使用API​​ Gateway作为基于Spring安全性的身份验证.我刚刚按照https://spring.io/guides/tutorials/spring-security-and-angular-js/链接中的步骤创建了一个基于其对应的github项目的"pair-double"模块的项目的https://github.com/spring-guides/tut-spring-security-and-angular-js.git.

问题
问题在于,当向服务器提交任何POST请求时,将抛出"无效的CSRF令牌"异常.抛出异常的示例如下:

{
  "timestamp": 1461714933215,
  "status": 403,
  "error": "Forbidden",
  "message": "Invalid CSRF Token '1cdc44ad-43cb-44e6-b903-bec24fe903fd' was found on the request parameter '_csrf' or header 'X-XSRF-TOKEN'.",
  "path": "/ui/test"
}
Run Code Online (Sandbox Code Playgroud)

我检查了一个重新检查的问题,但没有用.我用postman测试了这个场景,并将'X-XSRF-TOKEN'设置为POST请求的标题,但什么也没发生.


所以,由于我是初学者使用Spring安全方法,如果有人能建议我一个解决方案,我将不胜感激.

security post spring csrf angularjs

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

Spring Boot 使用基本身份验证连接到 Elasticsearch

概述:

我尝试了 API 和本地 Elasticsearch 之间的非安全连接,一切正常。为了确保连接安全,我执行了以下步骤在我的弹性体上添加 xpack 插件并在 api 中使用它:

  • 从弹性部分,我根据Install xpack安装了xpack ,并且Api之外一切都很好。然后添加用户名api和密码apipass作为新的弹性超级用户。
  • 从 API 方面,我更新了代码以实现安全连接: Java 客户端和安全性

我的代码在弹性配置中发生了变化:

@Bean
public TransportClient transportClient() throws UnknownHostException {
    Settings settings = Settings.builder()
        .put("cluster.name", clusterName)
        .put("xpack.security.user", "api:apipass")
        .build();
    try (TransportClient client = new PreBuiltXPackTransportClient(settings)
        .addTransportAddress(new TransportAddress(InetAddress.getByName(host), tcpPort))) {            
        String token = basicAuthHeaderValue("api", new SecureString("apipass".toCharArray()));
        client.filterWithHeader(Collections.singletonMap("Authorization", token))
            .prepareSearch().get();

        return client;
    }
}
Run Code Online (Sandbox Code Playgroud)

问题:

当尝试通过应用程序运行弹性查询时,将引发以下异常:

Caused by: java.lang.IllegalStateException: transport client is closed
at org.elasticsearch.client.transport.TransportClientNodesService.execute(TransportClientNodesService.java:243) ~[elasticsearch-6.0.0.jar:6.0.0]
at org.elasticsearch.client.transport.TransportProxyClient.execute(TransportProxyClient.java:59) ~[elasticsearch-6.0.0.jar:6.0.0]
at …
Run Code Online (Sandbox Code Playgroud)

elasticsearch elasticsearch-plugin spring-boot spring-data-elasticsearch elasticsearch-x-pack

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