小编dur*_*dur的帖子

升级到 Spring Boot 3 Swagger UI 后无法访问

我有一个 Spring Boot 2.7.6 应用程序,Spring Security 5.7.5 运行没有问题:身份验证有效,我根据角色浏览不同的页面,Swagger UI 可用等。我没有针对您的不推荐使用的警告信息。

\n

我迁移到 Spring Boot 3.0.0,因此迁移到 Spring Security 6.0.0。我按照迁移指南进行操作,服务器启动没有错误。但我的网址不再有效。我的状态是 401。

\n

问题#1:GET http://localhost:8080/swagger-ui/index.html导致客户端出现 401 错误。

\n

在日志中我有一个 404:

\n
DEBUG o.s.web.servlet.handler.SimpleUrlHandlerMapping    : Mapped to ResourceHttpRequestHandler [classpath [static/]]\nDEBUG o.s.web.servlet.handler.SimpleUrlHandlerMapping    : Mapped to ResourceHttpRequestHandler [classpath [static/]]\nDEBUG o.s.web.servlet.handler.SimpleUrlHandlerMapping    : Mapped to ResourceHttpRequestHandler [classpath [static/]]\nDEBUG o.s.web.servlet.handler.SimpleUrlHandlerMapping    : Mapped to ResourceHttpRequestHandler [classpath [static/]]\nDEBUG org.springframework.web.servlet.DispatcherServlet  : GET "/swagger-ui/index.html", parameters={}\nDEBUG o.s.web.servlet.handler.SimpleUrlHandlerMapping    : Mapped to ResourceHttpRequestHandler [classpath [static/]]\nDEBUG o.s.w.servlet.resource.ResourceHttpRequestHandler  : Resource not found\nDEBUG org.springframework.web.servlet.DispatcherServlet  : Completed 404 …
Run Code Online (Sandbox Code Playgroud)

java migration spring-security spring-boot springdoc-ui

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

为什么 Java 中的 JWT 令牌无效或过期时,我的 CustomAuthenticationEntryPoint 开始方法没有被调用?

当 jwt 令牌无效或过期时,为什么不调用此开始方法?当令牌为空时会调用它。奇怪的是,在调试时我发现当令牌无效或过期时,会调用 BearerTokenAuthenticationEntryPoint.commence() 方法。这个类是标准java库的一部分,并且是最终的,所以不能扩展。但它实现了与我实现相同的接口 - AuthenticationEntryPoint,但我的开始方法仍然没有被调用。仅当令牌为空时才会调用它。

public class CustomAuthenticationEntryPoint implements AuthenticationEntryPoint {
  public CustomAuthenticationEntryPoint() {
  }

  @Override
  public void commence(HttpServletRequest httpServletRequest, HttpServletResponse response, AuthenticationException authenticationException) throws IOException {
    response.setContentType(MediaType.APPLICATION_JSON_VALUE);
    response.setStatus(HttpServletResponse.SC_UNAUTHORIZED);
    HttpStatus status = HttpStatus.UNAUTHORIZED;

    final Map<String, Object> body = new HashMap<>();
    body.put("status", status.name());
    body.put("statusCode", status.value());
    body.put("message", "You need to login first in order to perform this action");

    final ObjectMapper mapper = new ObjectMapper();
    mapper.writeValue(response.getOutputStream(), body);
  }
}
Run Code Online (Sandbox Code Playgroud)

我这样使用它:

@Bean
public SecurityFilterChain securityFilterChain(HttpSecurity http) throws Exception {
    http
            .authorizeHttpRequests((authorize) -> …
Run Code Online (Sandbox Code Playgroud)

java spring-security jwt spring-resource-server

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

如何通过Jira REST Java Client获取项目的所有问题?

我正在尝试获得项目的所有问题,然后找到哪些已完成,但我不知道如何.
我将用户连接到Jira,并希望得到他所有的项目和所有问题.然后我想找到,完成了哪些问题.请问有人帮帮我吗?

我有这个:

Iterable <BasicProject> allProj;
this.yourUsername = userName;
this.yourPassword = password;

this.jiraServerUri = new URI("https://applifting.atlassian.net");
this.factory = new JerseyJiraRestClientFactory();;
this.restClient = factory.createWithBasicHttpAuthentication(jiraServerUri, yourUsername, yourPassword);
final NullProgressMonitor pm = new NullProgressMonitor();
allProj = this.restClient.getProjectClient().getAllProjects(pm);

for(Iterator<BasicProject> i = allProj.iterator(); i.hasNext(); ) {
    BasicProject proj = i.next();
    Project ActualProject = this.restClient.getProjectClient().getProject(proj.getKey(), pm);
    ComponentRestClient cm =

}
Run Code Online (Sandbox Code Playgroud)

我想在这个for循环中,当我拥有所有项目时,我应该得到所有问题.

jira jira-rest-java-api jira-rest-api

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

泽西客户端获取错误消息正文

我使用以下代码来使用休息服务

Client client = ClientBuilder.newClient();
WebTarget target = client.target("wrong url");
Invocation.Builder builder = target.request(MediaType.APPLICATION_JSON);
Response response = builder.post(Entity.entity(param, MediaType.APPLICATION_JSON), Response.class);
Run Code Online (Sandbox Code Playgroud)

正如所料,我收到了错误.和状态代码400 Bad Request.但我没有收到错误消息.当我运行时response.getStatusInfo()我得到了错误的请求,但我的服务器发送了额外的信

当我使用postman我在Body窗口中获取错误信息时调用它.

那么如何从响应对象中获取此错误正文信息?或任何其他方式???

java jax-rs jersey-client

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

在Spring Security中实现自定义身份验证

我想就Spring Security中的问题向您寻求帮助.我有一个要求,我必须根据用户选择的选项验证登录凭证.选项1将通过第三方服务验证登录用户.选项2是使用数据库身份验证级别的正常验证.我该如何实现呢?

java spring spring-security

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

如果有的话,在第二个空格后删除字符串中的所有内容

可以说我有这样的文字:Thundering Blow I.我需要的是使它看起来像Thundering Blow- 删除字符串末尾的罗马数字.

我尝试了trim()一些substring()方法,但他们都回来了:Thundering Blow I回到我身边.也许它可以删除I字符串中的所有内容?也可以,但我似乎无法找到解决问题的方法.

java string

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

是否可以从 Jenkins 脚本控制台发送电子邮件?

为了在新的 Jenkins 实例中自动注册用户,我生成了一个Groovy脚本:

// Automatically generated groovy script -- 1463047124
jenkins.model.Jenkins.instance.securityRealm.createAccount("username", "NGRkOGJiNGE2NDEyMTExMDI0OGZmOWNj")
def user = hudson.model.User.get("username");
def userEmail = "username@domain.com";
user.addProperty(new hudson.tasks.Mailer.UserProperty(userEmail)); 
Run Code Online (Sandbox Code Playgroud)

然后我可以将它粘贴到 Jenkins 脚本控制台或通过 Jenkins CLI 运行它,它会创建用户。

我想添加到此设置的下一件事是能够通过电子邮件通知新用户他们的帐户已创建。我怀疑这可以完成,因为“邮件程序”安装在我的 Jenkins 实例中。例如,使用流行的流水线即代码,我可以添加到我的 Jenkinsfile 中:

mail (to: "user@userland.com",
        subject: "Jenkins says",
        body: "No"); 
Run Code Online (Sandbox Code Playgroud)

它会发送它。但是,这无法在 CLI 或脚本控制台中重现。甚至有可能做到这一点吗?

groovy continuous-integration jenkins jenkins-cli

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

无法使用 Java 1.8 在 JBoss 5.1 中编译 JSP 文件

无法使用 Java 1.8 在 JBoss 5.1 中编译 JSP 文件。能够编译常规 Java 文件,甚至可以完成没有 JSP 的 Spring 项目。

如果我们为那些 JSP 文件保留编译好的类文件,它就可以正常工作。

以下是我在尝试运行 JSP 文件时遇到的错误:

2016-07-15 14:56:00,758 ERROR [org.apache.jasper.compiler.Compiler] (http-0.0.0.0-80-31) Compilation error
org.eclipse.jdt.internal.compiler.classfmt.ClassFormatException
        at org.eclipse.jdt.internal.compiler.classfmt.ClassFileReader.<init>(ClassFileReader.java:369)
        at org.apache.jasper.compiler.JDTCompiler$1.findType(JDTCompiler.java:206)
        at org.apache.jasper.compiler.JDTCompiler$1.findType(JDTCompiler.java:163)
        at org.eclipse.jdt.internal.compiler.lookup.LookupEnvironment.askForType(LookupEnvironment.java:97)
        at org.eclipse.jdt.internal.compiler.lookup.UnresolvedReferenceBinding.resolve(UnresolvedReferenceBinding.java:49)
        at org.eclipse.jdt.internal.compiler.lookup.BinaryTypeBinding.resolveType(BinaryTypeBinding.java:101)
        at org.eclipse.jdt.internal.compiler.lookup.PackageBinding.getTypeOrPackage(PackageBinding.java:169)
        at org.eclipse.jdt.internal.compiler.lookup.Scope.getType(Scope.java:2241)
        at org.eclipse.jdt.internal.compiler.ast.TypeDeclaration.resolve(TypeDeclaration.java:974)
        at org.eclipse.jdt.internal.compiler.ast.TypeDeclaration.resolve(TypeDeclaration.java:1184)
        at org.eclipse.jdt.internal.compiler.ast.CompilationUnitDeclaration.resolve(CompilationUnitDeclaration.java:535)
        at org.eclipse.jdt.internal.compiler.Compiler.process(Compiler.java:743)
        at org.eclipse.jdt.internal.compiler.Compiler.compile(Compiler.java:444)
        at org.apache.jasper.compiler.JDTCompiler.generateClass(JDTCompiler.java:429)
        at org.apache.jasper.compiler.Compiler.compile(Compiler.java:335)
        at org.apache.jasper.compiler.Compiler.compile(Compiler.java:313)
        at org.apache.jasper.compiler.Compiler.compile(Compiler.java:300)
        at org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:585)
        at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:312)
        at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:322)
        at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:249)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
        at org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96)
        at …
Run Code Online (Sandbox Code Playgroud)

java jsp jboss5.x java-8

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

如何在DataGridView上创建固定的背景

我做了一个自定义控件继承DataGridView,以便有一个透明的背景.现在我试图在计时器上设置一个滚动功能,每秒向下滚动一行.但是,当我尝试滚动(垂直)时,背景图像不固定.滚动时有没有办法使背景图像固定?

编辑:这是处理滚动计时器的代码.

Private Sub Sub1

    'Some previous code

    If DataGridView1.Rows.Count > 10 Then
        ScrollIndex1 = 0 'Integer for scroll index
        DGVAutoScroll()
    End If

End Sub

Private Sub DGVAutoScroll()

    Timer2.Enabled = True
    Timer2.Interval = 1000

End Sub

Private Sub Timer2_Tick(sender As Object, e As EventArgs) Handles Timer2.Tick

    If ScrollIndex1 = DataGridView1.Rows.Count - 1 Then
        ScrollIndex1 = 0
        DataGridView1.FirstDisplayedScrollingRowIndex = ScrollIndex1
        ScrollIndex1 += 1
    Else
        DataGridView1.FirstDisplayedScrollingRowIndex = ScrollIndex1
        ScrollIndex1 += 1
    End If

End Sub

'Custom DataGridView class
Imports System.ComponentModel …
Run Code Online (Sandbox Code Playgroud)

vb.net datagridview

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

atari-py 的构建轮失败

我想:

pip install atari-py
Run Code Online (Sandbox Code Playgroud)

在 Python 3.5 上,我得到:

atari-py 的构建轮失败

python-3.x

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