Я добавил именно эти 2 класса, чтобы обойти проблему CORS, как было предложено здесь Хенди Ираван: Spring Security CORS Filter (1-й) ответ .
Просто одно отличие во втором классе (public class MyFilter extends OncePerRequestFilter
), я использовал Arrays.asList("...")
вместо ImmutableList.of("...")
Это мой контроллер отдыха
@RestController
public class UsersProfileController {
@Autowired UserProfInterface userProfInterface;
@GetMapping("/connector/{username}/users")
public List<UserProfilesEntity> getAllUsers(
@PathVariable String username) {
return userProfInterface.getAllUsers();
}
Это возвращает JSON вот так : 4: {idUserProfiles: 10, firstName: "Aris2", lastName: "Testy", dateOfBirth: 28936800000}
dateOfBirth
на MySQL БД выглядит так: 1970-12-02
Как только я отключу зависимость Spring-Security, Дата рождения появится правильно в файле JSON и мой внешний вид (я использую Reactjs).
Мой 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.3.2.RELEASE</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<groupId>com.bootcamp</groupId>
<artifactId>connector</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>war</packaging>
<name>connector</name>
<description>Demo project for Spring Boot</description>
<properties>
<java.version>11</java.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
</dependency>
<!-- <dependency>-->
<!-- <groupId>org.springframework.boot</groupId>-->
<!-- <artifactId>spring-boot-starter-data-rest</artifactId>-->
<!-- </dependency>-->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-devtools</artifactId>
<scope>runtime</scope>
<optional>true</optional>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-security</artifactId>
</dependency>
<dependency>
<groupId>com.h2database</groupId>
<artifactId>h2</artifactId>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-tomcat</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
<exclusions>
<exclusion>
<groupId>org.junit.vintage</groupId>
<artifactId>junit-vintage-engine</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-thymeleaf</artifactId>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
</project>
Я использую Spring Security
версию 5.3.3
Я давно посетил Stackoverflow и спрашиваю впервые, поэтому буду благодарен за любые отзывы.