здесь это код в файле конфигурации:
Код: Выделить всё
package Security;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity;
import org.springframework.security.web.SecurityFilterChain;
@Configuration
@EnableWebSecurity
public class securityConfiguration {
@Bean
public SecurityFilterChain configure(HttpSecurity Sec ) throws Exception {
Sec
.authorizeRequests()
.anyRequest()
.authenticated()
.and()
.httpBasic();
return Sec.build();}
}
Код: Выделить всё
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
4.0.0
org.springframework.boot
spring-boot-starter-parent
3.0.2
com.example
test
0.0.1-SNAPSHOT
test
test
17
org.springframework.boot
spring-boot-starter-security
org.springframework.boot
spring-boot-starter-thymeleaf
org.springframework.boot
spring-boot-starter-web
org.thymeleaf.extras
thymeleaf-extras-springsecurity6
com.mysql
mysql-connector-j
runtime
org.springframework.boot
spring-boot-starter-test
test
org.springframework.security
spring-security-test
test
org.springframework.boot
spring-boot-maven-plugin
Подробнее здесь: https://stackoverflow.com/questions/755 ... onfig-file