标签: spring-boot

未找到 Spring 安全 OpenSAML 4.1.1 工件

我有一个 Maven 多模块项目,在 saml2 场景中使用 spring boot 2.6.4 和 spring security。

据我所知,spring 使用 opensaml,更准确地说是 opensaml 4.1.1

我将此依赖项添加到我的 saml maven 模块的 pom 中:

<dependency>
  <groupId>org.opensaml</groupId>
  <artifactId>opensaml-core</artifactId>
  <version>4.1.1</version>
</dependency>
<dependency>
  <groupId>org.opensaml</groupId>
  <artifactId>opensaml-saml-api</artifactId>
  <version>4.1.1</version>
  <exclusions>
    <exclusion>
      <artifactId>*</artifactId>
      <groupId>*</groupId>
    </exclusion>
  </exclusions>
</dependency>
<dependency>
  <groupId>org.opensaml</groupId>
  <artifactId>opensaml-saml-impl</artifactId>
  <version>4.1.1</version>
  <exclusions>
    <exclusion>
      <artifactId>*</artifactId>
      <groupId>*</groupId>
    </exclusion>
  </exclusions>
</dependency>
<dependency>
  <groupId>org.opensaml</groupId>
  <artifactId>opensaml-security-api</artifactId>
  <version>4.1.1</version>
  <exclusions>
    <exclusion>
      <artifactId>*</artifactId>
      <groupId>*</groupId>
    </exclusion>
  </exclusions>
</dependency>
<dependency>
  <groupId>org.opensaml</groupId>
  <artifactId>opensaml-security-impl</artifactId>
  <version>4.1.1</version>
  <exclusions>
    <exclusion>
      <artifactId>*</artifactId>
      <groupId>*</groupId>
    </exclusion>
  </exclusions>
</dependency>
<dependency>
  <groupId>org.opensaml</groupId>
  <artifactId>opensaml-profile-api</artifactId>
  <version>4.1.1</version>
  <exclusions>
    <exclusion>
      <artifactId>*</artifactId>
      <groupId>*</groupId>
    </exclusion> …
Run Code Online (Sandbox Code Playgroud)

spring-security maven opensaml spring-boot

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

无法在 Spring boot 中更新文档。在 mongorepository.save 上出现 E11000 重复密钥错误

我无法执行更新操作。将 spring boot 与 mongodb 3.4 结合使用。在尝试保存时,我收到以下错误:

WriteError{code=11000, message='E11000重复键错误集合

我的域类正在扩展另一个基域类。我目前的发现是基域类包含用 @Version 注释的“私有长版本”。我的猜测是这是导致问题的领域。到目前为止我尝试过的事情:

  • 初始化“private Long version = 0L;” 我的文档仅更新一次,进一步更新会出现以下错误:

更新 Employee 时服务层出现问题。无法将版本 1 的实体 119794669940 保存到 Employee 集合。同时修改了吗?

WriteError{code=11000, message='E11000重复键错误集合。

一些附加信息:

  • 在迄今为止我尝试过的上述任何情况下,我都没有在放置正文中发送版本(使用版本密钥发送它们会给出相同的错误。

任何人都知道发生了什么事或如何进一步进行?

java spring spring-data-mongodb spring-boot

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

vaadin hilla 代替 flow 有什么问题

我使用 vaadin 和 flow 开发 web 应用程序已经有一段时间了(与 Spring Boot 一起),并且偶然发现了 hilla,一个新的 vaadin“插件”或项目...(www.hilla.dev)。

我知道 flow 和 vaadin 使用 typescript 来做一些事情,但我从来不需要深入研究我的 java 后端和生成的 html/js/css 之间的这个元层......

所以我问自己,hilla 有什么用处让我的生活变得更轻松?或者,hilla 是否更适合从 javascript 和 typescript 转向 vaadin 的人,而不是相反?

vaadin spring-boot vaadin-flow hilla

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

错误的请求响应,缺少字段名称 - Spring Boot

我有一个 API 端点,可以获取名称和描述参数(两者都是必需的)

createSomething(@RequestParam(value = "name") String name,@RequestParam(value = "description") String description)
Run Code Online (Sandbox Code Playgroud)

如果客户没有提供其中任何一个,他将收到 400 Bad Request

我有办法告诉客户缺少哪个字段吗?提供有关“错误请求”响应的更多信息

更新:请注意,这些参数必须是强制性的,因为我希望 OpenAPI 能够检测到这些参数是强制性的。因此,诸如“可选”和检查函数体内之类的解决方案并不是我想要的

java rest spring query-string spring-boot

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

Spring中的PropertyEditor、Formatter和Converter有什么区别?

事实Spring MVC证明,我可以通过多种不同的方式绑定我的表单,但我真的感觉自己迷路了。a 的和方法与具有不同名称(parse和)的 a 的方法等效。同样,我可以实现一个或两个s 来完成完全相同的事情。printFormatterPropertyEditorSupportgetAsTextsetAsTextGenericConverter Converter<S,T>

我在此处Formatters阅读了一条替代 的评论PropertyEditor,但我没有找到任何支持它的文档,而且它甚至还没有被弃用。

我的问题是,当涉及到将数据从表单绑定到对象时,正确的方法是什么spring-mvcPropertyEditorSpring 中,Formatter和之间的主要区别是什么Converter?每一种的用例是什么?对我来说,他们似乎负有同样的责任。

java spring spring-mvc spring-boot

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

更正应用程序的类路径,使其包含兼容版本

我正在尝试将一些服务从一个 Spring Boot 项目迁移到另一个项目,当然存在很多问题,但除了我陷入困境之外,所有问题都已解决

更正应用程序的类路径,使其包含类 org.springframework.boot.sql.init.dependency.AnnotationDependsOnDatabaseInitializationDetector 和 org.springframework.beans.factory.config.ConfigurableListableBeanFactory 的兼容版本

这是我的 pom.xml

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>
<!--    <parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>2.6.5</version>
        <relativePath/> &lt;!&ndash; lookup parent from repository &ndash;&gt;
    </parent>-->
    <groupId>com.hpw</groupId>
    <artifactId>box</artifactId>
    <version>0.0.1-SNAPSHOT</version>
    <name>box</name>
    <description>Box</description>
    <properties>
        <java.version>17</java.version>
        <maven.compiler.source>17</maven.compiler.source>
        <maven.compiler.target>17</maven.compiler.target>
    </properties>
    <dependencies>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter</artifactId>
            <version>2.6.4</version>
        </dependency>

        <dependency>
            <groupId>org.projectlombok</groupId>
            <artifactId>lombok</artifactId>
            <version>1.18.22</version>
            <scope>provided</scope>
        </dependency>

        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-test</artifactId>
            <version>2.6.5</version>
            <scope>test</scope>
        </dependency>

        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-web</artifactId>
        </dependency>

        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-web</artifactId>
            <version>5.3.13</version>
        </dependency>

        <dependency>
            <groupId>javax.servlet</groupId>
            <artifactId>servlet-api</artifactId>
            <version>2.5</version>
            <scope>provided</scope>
        </dependency>

        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-data-jpa</artifactId>
            <version>2.6.4</version> …
Run Code Online (Sandbox Code Playgroud)

maven-plugin pom.xml maven-3 spring-boot

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

Kotlin Spring:未解析的参考 =&gt; 复制

我正在学习 Kotlin 和 Spring,并正在开发迷你项目来学习经验。此功能用于更新已创建/添加的待办事项,并通过 ID 找到它并更新数据。但我得到了Unresolved Reference: copy,但没有找到任何文档。

fun putTodo(id: Long, newTodo: Todo): ResponseEntity<Todo> =
  todoRepository.findById(id).map { currentTodo ->
    val updatedTodo: Todo = 
      currentTodo.copy(
        title = newTodo.title,
        status = newTodo.status
      )
    ResponseEntity.ok().body(todoRepository.save(updatedTodo))
  }.orElse(ReponseEntity.notFound().build())
Run Code Online (Sandbox Code Playgroud)

kotlin spring-boot

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

如何在Java中使用Spring boot ResponseEnity中的Eclipse集合

因此,我需要帮助使用 java eclipse 集合作为使用 spring boot Response Entity JSON 的响应的一部分。我尝试过使用通用方法,但收到一个响应异常错误,它无法转换为 java ArrayList 类型,因此任何人都可以提供使用 eclipse 集合数据而不是 java 集合列表的正常休息端点的示例吗?

这是一个示例代码

 @GetMapping("/list")
public ResponseEntity<MutableList<Person>> getData() {

    return ResponseEntity.ok(Map.of(
                    "success", true,
                    
                    "data", Map.of(
                            "users", personService.getUsers()
                    )
            ));

}
Run Code Online (Sandbox Code Playgroud)

java java-8 spring-boot eclipse-collections

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

Gradle 找不到 Spring Boot 3.0.0-M1

我不知道如何调试这个或根本出了什么问题。我正在尝试运行这个项目:https://github.com/spring-projects/spring-security-samples/tree/main/servlet/spring-boot/java/jwt/login

在项目中,使用Spring Boot 3.0.0-M1来展示JWT身份验证的最新可能性。但是,无论我做什么,我的 Gradle 都找不到这个 Spring Boot 版本。当我将其设置为2.6.6时,它再次工作,但它似乎无法找到3.0.0-M1。

当我尝试同步依赖项时,出现以下错误:

Build file 'C:\my files\general\subjects\programming\Open-source\spring-security-samples\servlet\spring-boot\java\jwt\login\build.gradle' line: 2

Plugin [id: 'org.springframework.boot', version: '3.0.0-M1'] was not found in any of the following sources:

* Try:
> Run with --stacktrace option to get the stack trace.
> Run with --info or --debug option to get more log output.
> Run with --scan to get full insights.
Run Code Online (Sandbox Code Playgroud)

Gradle配置如下:

plugins {
    id 'org.springframework.boot' version '3.0.0-M1'
    id 'io.spring.dependency-management' version '1.0.11.RELEASE'
    id 'java'
}

repositories {
    mavenCentral() …
Run Code Online (Sandbox Code Playgroud)

spring dependencies gradle maven spring-boot

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

java.lang.NoSuchMethodError: org.mockito.Answers.get()Lorg/mockito/stubbing/Answer;

我正在尝试将 spring boot 版本从 2.2.4 升级到 2.6.6。我能够成功编译应用程序并且能够启动应用程序。但是当我尝试运行测试时,所有测试都因一个错误而失败:

java.lang.NoSuchMethodError: org.mockito.Answers.get()Lorg/mockito/stubbing/Answer;

我在所有测试中都遇到相同的错误。

这是我的主要 pom 文件:

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>

    <groupId>com.iodine.imc</groupId>
    <artifactId>imc</artifactId>
    <packaging>pom</packaging>
    <version>0.0.1-SNAPSHOT</version>
    <modules>
        <module>imc-core</module>
        <module>imc-restapi</module>
        <module>imc-ui</module>
    </modules>

    <name>imc-parent</name>
    <description>IMC</description>

    <prerequisites>
        <maven>3.0</maven>
    </prerequisites>

    <parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>2.6.6</version>
        <relativePath />
    </parent>
    <build>
        <resources>
            <resource>
                <directory>src/main/resources</directory>
                <includes>
                    <include>build.properties</include>
                </includes>
                <filtering>true</filtering>
            </resource>
            <resource>
                <directory>src/main/resources</directory>
                <excludes>
                    <exclude>build.properties</exclude>
                </excludes>
                <filtering>false</filtering>
            </resource>
        </resources>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>3.1</version>
                <configuration>
                    <source>1.8</source>
                    <target>1.8</target>
                    <compilerId>groovy-eclipse-compiler</compilerId>
                    <source>${java.version}</source>
                    <target>${java.version}</target>
                    <verbose>true</verbose>
                </configuration>
                <dependencies>
                    <dependency>
                        <groupId>org.springframework</groupId>
                        <artifactId>spring-dao</artifactId>
                        <version>2.0.8</version>
                    <dependency>
                        <groupId>org.codehaus.groovy</groupId> …
Run Code Online (Sandbox Code Playgroud)

mockito powermock maven spring-boot vaadin8

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