我有一个 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 boot 与 mongodb 3.4 结合使用。在尝试保存时,我收到以下错误:
WriteError{code=11000, message='E11000重复键错误集合
我的域类正在扩展另一个基域类。我目前的发现是基域类包含用 @Version 注释的“私有长版本”。我的猜测是这是导致问题的领域。到目前为止我尝试过的事情:
更新 Employee 时服务层出现问题。无法将版本 1 的实体 119794669940 保存到 Employee 集合。同时修改了吗?
WriteError{code=11000, message='E11000重复键错误集合。
一些附加信息:
任何人都知道发生了什么事或如何进一步进行?
我使用 vaadin 和 flow 开发 web 应用程序已经有一段时间了(与 Spring Boot 一起),并且偶然发现了 hilla,一个新的 vaadin“插件”或项目...(www.hilla.dev)。
我知道 flow 和 vaadin 使用 typescript 来做一些事情,但我从来不需要深入研究我的 java 后端和生成的 html/js/css 之间的这个元层......
所以我问自己,hilla 有什么用处让我的生活变得更轻松?或者,hilla 是否更适合从 javascript 和 typescript 转向 vaadin 的人,而不是相反?
我有一个 API 端点,可以获取名称和描述参数(两者都是必需的)
createSomething(@RequestParam(value = "name") String name,@RequestParam(value = "description") String description)
Run Code Online (Sandbox Code Playgroud)
如果客户没有提供其中任何一个,他将收到 400 Bad Request
我有办法告诉客户缺少哪个字段吗?提供有关“错误请求”响应的更多信息
更新:请注意,这些参数必须是强制性的,因为我希望 OpenAPI 能够检测到这些参数是强制性的。因此,诸如“可选”和检查函数体内之类的解决方案并不是我想要的
事实Spring MVC证明,我可以通过多种不同的方式绑定我的表单,但我真的感觉自己迷路了。a 的和方法与具有不同名称(parse和)的 a 的方法等效。同样,我可以实现一个或两个s 来完成完全相同的事情。printFormatterPropertyEditorSupportgetAsTextsetAsTextGenericConverter Converter<S,T>
我在此处Formatters阅读了一条替代 的评论PropertyEditor,但我没有找到任何支持它的文档,而且它甚至还没有被弃用。
我的问题是,当涉及到将数据从表单绑定到对象时,正确的方法是什么spring-mvc?PropertyEditorSpring 中,Formatter和之间的主要区别是什么Converter?每一种的用例是什么?对我来说,他们似乎负有同样的责任。
我正在尝试将一些服务从一个 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/> <!– lookup parent from repository –>
</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) 我正在学习 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) 因此,我需要帮助使用 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) 我不知道如何调试这个或根本出了什么问题。我正在尝试运行这个项目: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 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) spring-boot ×10
java ×4
spring ×4
maven ×3
dependencies ×1
gradle ×1
hilla ×1
java-8 ×1
kotlin ×1
maven-3 ×1
maven-plugin ×1
mockito ×1
opensaml ×1
pom.xml ×1
powermock ×1
query-string ×1
rest ×1
spring-mvc ×1
vaadin ×1
vaadin-flow ×1
vaadin8 ×1