spring 相关问题

Spring Framework是Java平台上应用程序开发的开源框架。其核心是对基于组件的体系结构的丰富支持,目前它拥有20多个高度集成的模块。

如何记录 Gmail API 的响应?

我的应用程序与 Gmail API 集成。 我想查看(记录)我从 Gmail API 获得的完整原始响应 创建 Gmail 存根。 我使用 Java 和 Spring Boot。 例如,我想看到回复......

回答 1 投票 0

这个 Apache Derby 语法错误是什么,如何修复它?

我正在关注这个优秀的 Spring Boot 快速入门教程。我做得很好,直到进入会话#29,我将我的服务连接到嵌入式 Apache Derby DB,并实现 GET...

回答 1 投票 0

通过服务器 Spring Boot 应用程序将文件从 Android 设备发送到 AWS S3

我想通过heroku服务器上的spring boot应用程序将mp4文件从android设备发送到AWS S3存储桶。 我应该在 Android 应用程序端使用哪种方法来发送文件? 我得到了...

回答 1 投票 0

org.springframework.boot.SpringApplication 在 Springboot 2.2.5 版本中未解决

Eclipse 在 SpringApplication 类上显示错误,而 mvn clean install 构建成功。 我正在使用 java 1.8、Maven 3.3.6、Springboot 2.2.5。 下面是代码。 导入 org.springframework...

回答 1 投票 0

开发 Jmix 2.x 自定义 UI DB 交互

对于一个公司项目,我们正在 Jmix https://www.jmix.io/ 上进行开发。 我们需要创建 GUI 到数据库的交互,以便从实体获取值并将其放在经典 UI 组件上,然后进行编辑...

回答 1 投票 0

开发Jmix自定义UI DB交互

对于一个公司项目,我们正在 Jmix https://www.jmix.io/ 上进行开发。 我们需要创建 Jmix 到 GUI 到 DB 的交互,以便从实体获取值并将其放在经典 UI 组件上。编辑

回答 1 投票 0

Spring Security如何将principal注入到Controller中?

我可以像下面的代码一样获取用户主体,但我很困惑Spring Security如何知道注入正确的主体。通常,我们会传递 args 来调用带参数的方法。那么,哪里

回答 2 投票 0

在运行时更改 Spring 任务的预定时间?

或者,如果失败,请从调度程序中删除任务并添加新任务。 恐怕这是 Spring 的一部分,我或多或少 100% 无知,花了一个下午阅读关于我的文章......

回答 1 投票 0

Maven Surefire 中的 Log4j2 自定义 Appender:可以跨线程重用吗?

我有一个 Log4j2 自定义附加程序,在我的许多 JUnit5 测试中都使用它。 (就其价值而言,我在几篇文章中发现了该代码,并且只做了一些微小的调整。) 当在 Su 中运行时...

回答 1 投票 0

由于无法创建bean而出现空指针异常

<?xml version="1.0" encoding="UTF-8"?> <beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:aop="http://www.springframework.org/schema/aop" xmlns:tx="http://www.springframework.org/schema/tx" default-autowire="byName" xmlns:oxm="http://www.springframework.org/schema/oxm" xmlns:mvc="http://www.springframework.org/schema/mvc" xsi:schemaLocation="http://www.springframework.org/schema/oxm http://www.springframework.org/schema/oxm/spring-oxm-4.3.xsd http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-4.3.xsd http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-4.3.xsd http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-4.3.xsd http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-4.3.xsd"> <bean id="userRoleDAOTarget" class="com.revguru.crs.security.dao.UserRoleDAOImpl" scope="prototype"> <property name="sessionFactory" ref="hsdSessionFactory" /> </bean> <bean id="userAuthDAOTarget" class="com.revguru.crs.security.dao.AuthenticationDAOImpl" scope="prototype"> <property name="sessionFactory" ref="hsdSessionFactory" /> </bean> <bean id="hotelUserDAOTarget" class="com.revguru.crs.security.dao.HotelUserDAOImpl" scope="prototype"> <property name="sessionFactory" ref="hsdSessionFactory" /> </bean> <bean id="userRoleDataObjprocessor" class="com.revguru.crs.security.service.UserRoleProcessor" scope="prototype"> <property name="userRoleDAO" ref="hsdSecurityObjectDAO" /> </bean> <bean id="userAuthDataObjprocessor" class="com.revguru.crs.security.service.AuthenticationProcessor" scope="prototype"> <property name="authenticationDAO" ref="hsdSecurityAuthObjectDAO" /> <property name="messages" ref="userSectionMessageSource"/> </bean> <bean id="hotelUserDataObjProcessor" class="com.revguru.crs.security.service.HotelUserProcessor" scope="prototype"> <property name="hotelUserDAO" ref="hsdHotelUserDAO" /> <property name="securitySectionLogger" ref="generalServiceLogger"/> </bean> <bean id="SECURITY_SERVICE" class="com.revguru.crs.core.service.sc.SecurityService" scope="prototype"> <property name="userRoleProcessor" ref="userRoleDataObjprocessor" /> <property name="userAuthProcessor" ref="userAuthDataObjprocessor" /> <property name="hotelUserProcessor" ref="hotelUserDataObjProcessor" /> </bean> <bean id="hsdSecurityObjectDAO" class="org.springframework.aop.framework.ProxyFactoryBean"> <property name="proxyInterfaces"> <value>com.revguru.crs.security.dao.UserRoleDAO </value> </property> <property name="interceptorNames"> <list> <value>hibernateInterceptor</value> <value>userRoleDAOTarget</value> </list> </property> </bean> <bean id="hsdSecurityAuthObjectDAO" class="org.springframework.aop.framework.ProxyFactoryBean"> <property name="proxyInterfaces"> <value>com.revguru.crs.security.dao.AuthenticationDAO </value> </property> <property name="interceptorNames"> <list> <value>hibernateInterceptor</value> <value>userAuthDAOTarget</value> </list> </property> </bean> <bean id="hsdHotelUserDAO" class="org.springframework.aop.framework.ProxyFactoryBean"> <property name="proxyInterfaces"> <value>com.revguru.crs.security.dao.HotelUserDAO </value> </property> <property name="interceptorNames"> <list> <value>hibernateInterceptor</value> <value>hotelUserDAOTarget</value> </list> </property> </bean> <bean id="userSectionMessageSource" class="org.springframework.context.support.ResourceBundleMessageSource" scope="prototype"> <property name="alwaysUseMessageFormat" value="true"/> <property name="basenames"> <list> <value>userauthResources/hsd_user_msg</value> </list> </property> </bean> </beans> 这是我的bean文件,它正在引用hsdsessionFscory,其定义如下: <bean id="dataSource" destroy-method="close" class="org.apache.commons.dbcp.BasicDataSource"> <property name="driverClassName" value="com.mysql.jdbc.Driver" /> <property name="url" value="jdbc:mysql://127.0.0.1:3306/revguru"/> <property name="username" value="root" /> <property name="password" value="decoder" /> </bean> <bean id="hsdSessionFactory" class="org.springframework.orm.hibernate5.LocalSessionFactoryBean"> <property name="dataSource" ref="dataSource" /> <property name="hibernateProperties"> 当我运行我的项目时,我得到空指针异常 public class UserLoginController { private FacesContext facesContext = FacesContext.getCurrentInstance(); HttpSession session = (HttpSession)FacesContext.getCurrentInstance().getExternalContext().getSession(true); private SecurityService securityService; public void setSecurityService(SecurityService securityService) { this.securityService = securityService; } public SecurityService getSecurityService() { return this.securityService; } /** * Authenticate the User * @return */ public String authenticate() { if(session.getAttribute("menus") != null) { session.removeAttribute("menus"); } if (session.getAttribute("CommonGlobalBean") != null) { session.removeAttribute("CommonGlobalBean"); } CommonGlobalBean commonGlobalBean = new CommonGlobalBean(); commonGlobalBean.setTimeZone(TimeZone.getDefault().getID()); UserLogin userLogin =(UserLogin)session.getAttribute("UserLogin"); String username = userLogin.getUserName(); String password = userLogin.getPassword(); UserInformation userInformation = null; System.out.println("security serv ice is "); if(securityService==null){ System.out.println("security serv ice is null:"); securityService= new SecurityService(); } if (userLogin != null) { System.out.println("username is:"+username); System.out.println("password is:"+password); if (securityService.authenticate(username,password)) { Util.log("Get User Object by Email"); UserDataObject userDataObject = securityService.getUserObjectByEmail(userLogin.getUserName()); Util.log("User name : "+userDataObject.getUserFirstName()); userInformation = (UserInformation)session.getAttribute("UserObject"); if (userInformation != null) { session.removeAttribute("UserObject"); } userInformation = getUserInformation(userDataObject); session.setAttribute("UserObject", userInformation); if(!checkUserAsHotelRole(userInformation)) { Util.log("User does not have hotel role."); Util.reportError(facesContext, "login_user_not_valid_password", null); } HotelDataObject hotelDataObject = getAssignedHotel(userInformation); session.setAttribute("hotelDataObjectInSession", hotelDataObject); List<Menu> menus = new ArrayList<Menu>(); for (FeatureDataObject feature : userInformation.getFeatureDataObjects()) { if (feature.getParentFeatureId() == null && feature.getFeatureTypeId().getId().intValue() == HSDServiceConstants.MENU && feature.getShowFeature() == 1) { List<MenuItem> menuItems = getMenuItems(feature.getId(), userInformation.getFeatureDataObjects()); menus.add(new Menu(feature.getId(), feature.getFeatureName(), "", menuItems)); } } String languageCode = userLogin.getLanguageCode(); if (languageCode == null) { userLogin.setLanguageCode("en"); facesContext.getViewRoot().setLocale(Locale.ENGLISH); } else { if(languageCode.equals("fr")) { facesContext.getViewRoot().setLocale(Locale.FRENCH); } else { facesContext.getViewRoot().setLocale(Locale.ENGLISH); } } Util.log(":: languageCode :: " + userLogin.getLanguageCode()); session.setAttribute("menus", menus); session.setAttribute("CommonGlobalBean", commonGlobalBean); /** * get hotel general info details */ GeneralHotelController generalHotelController = new GeneralHotelController(); generalHotelController.loadGeneralInformation(); /** * return to hotel general info page */ return "generalInfo"; } else { Util.log("Invalid User."); Util.reportError(facesContext, "login_user_not_valid_password", null); } } return ""; } 调用另一个方法来类如下 public boolean authenticate(String email, String password) { log.info("Authenticating : " + email); UserDataObject user = getUserObjectByEmail(email); if (user == null) { log.info("User does not exist for email id :" + email); return false; } return checkPassword(password, user.getPassword()); } 当我在 Spring Explorer 中看到它时,它显示 Bean ref 未知 这是我的堆栈跟踪 javax.servlet.ServletException: java.lang.NullPointerException javax.faces.webapp.FacesServlet.service(FacesServlet.java:659) io.undertow.servlet.handlers.ServletHandler.handleRequest(ServletHandler.java:85) io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:129) org.apache.myfaces.webapp.filter.ExtensionsFilter.doFilter(ExtensionsFilter.java:357) io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61) io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131) io.undertow.servlet.handlers.FilterHandler.handleRequest(FilterHandler.java:84) io.undertow.servlet.handlers.security.ServletSecurityRoleHandler.handleRequest(ServletSecurityRoleHandler.java:62) io.undertow.servlet.handlers.ServletDispatchingHandler.handleRequest(ServletDispatchingHandler.java:36) org.wildfly.extension.undertow.security.SecurityContextAssociationHandler.handleRequest(SecurityContextAssociationHandler.java:78) io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43) io.undertow.servlet.handlers.security.SSLInformationAssociationHandler.handleRequest(SSLInformationAssociationHandler.java:131) io.undertow.servlet.handlers.security.ServletAuthenticationCallHandler.handleRequest(ServletAuthenticationCallHandler.java:57) io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43) io.undertow.security.handlers.AbstractConfidentialityHandler.handleRequest(AbstractConfidentialityHandler.java:46) io.undertow.servlet.handlers.security.ServletConfidentialityConstraintHandler.handleRequest(ServletConfidentialityConstraintHandler.java:64) io.undertow.security.handlers.AuthenticationMechanismsHandler.handleRequest(AuthenticationMechanismsHandler.java:60) io.undertow.servlet.handlers.security.CachedAuthenticatedSessionHandler.handleRequest(CachedAuthenticatedSessionHandler.java:77) io.undertow.security.handlers.NotificationReceiverHandler.handleRequest(NotificationReceiverHandler.java:50) io.undertow.security.handlers.AbstractSecurityContextAssociationHandler.handleRequest(AbstractSecurityContextAssociationHandler.java:43) io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43) org.wildfly.extension.undertow.security.jacc.JACCContextIdHandler.handleRequest(JACCContextIdHandler.java:61) io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43) io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43) io.undertow.servlet.handlers.ServletInitialHandler.handleFirstRequest(ServletInitialHandler.java:292) io.undertow.servlet.handlers.ServletInitialHandler.access$100(ServletInitialHandler.java:81) io.undertow.servlet.handlers.ServletInitialHandler$2.call(ServletInitialHandler.java:138) io.undertow.servlet.handlers.ServletInitialHandler$2.call(ServletInitialHandler.java:135) io.undertow.servlet.core.ServletRequestContextThreadSetupAction$1.call(ServletRequestContextThreadSetupAction.java:48) io.undertow.servlet.core.ContextClassLoaderSetupAction$1.call(ContextClassLoaderSetupAction.java:43) io.undertow.servlet.api.LegacyThreadSetupActionWrapper$1.call(LegacyThreadSetupActionWrapper.java:44) io.undertow.servlet.api.LegacyThreadSetupActionWrapper$1.call(LegacyThreadSetupActionWrapper.java:44) io.undertow.servlet.api.LegacyThreadSetupActionWrapper$1.call(LegacyThreadSetupActionWrapper.java:44) io.undertow.servlet.api.LegacyThreadSetupActionWrapper$1.call(LegacyThreadSetupActionWrapper.java:44) io.undertow.servlet.api.LegacyThreadSetupActionWrapper$1.call(LegacyThreadSetupActionWrapper.java:44) io.undertow.servlet.handlers.ServletInitialHandler.dispatchRequest(ServletInitialHandler.java:272) io.undertow.servlet.handlers.ServletInitialHandler.access$000(ServletInitialHandler.java:81) io.undertow.servlet.handlers.ServletInitialHandler$1.handleRequest(ServletInitialHandler.java:104) io.undertow.server.Connectors.executeRootHandler(Connectors.java:202) io.undertow.server.HttpServerExchange$1.run(HttpServerExchange.java:805) java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) java.lang.Thread.run(Thread.java:745) 我的 Spring Explorer 中的红色标记是什么? 而其他人没有 UserLoginController 没有在您的 XML 中配置为 bean(至少在您发布的 XML 中没有),因此 Spring 对它一无所知,您也得不到注入。 尝试添加这个(当然是完整的包): <bean id="loginController" class="com.revguru.crs.security.dao.AuthenticationDAOImpl" scope="prototype"> <property name="securityService" ref="SECURITY_SERVICE" /> </bean>

回答 1 投票 0

如何根据 OpenAPI 规范仅生成 @HttpExchange 和 DTO?

我有一个 OpenAPI 规范文件,但我无法让 openapi-generator-maven-plugin 只生成 Spring @HttpExchange 接口和 DTO(模型类)。 我能得到的最接近的是使用...

回答 1 投票 0

无法使用Spring Cloud Kafka Binder处理消息

在下面的代码中,我尝试通过 REST 端点调用 processOrder() 来创建消息。然后,我想将 processOrder() 的结果传递给 processShipping() 和 processPayment。 然而...

回答 1 投票 0

Spring Boot 配置值带有 .no。或没有。未填充

我有一个非常简单的 Spring Boot 应用程序,具有特定于国家/地区的配置属性,所有已知且简单的东西,没有什么特别的。 它应该在 DK、SE、FI 和 NO 4 个国家/地区工作。注射这些正确的...

回答 1 投票 0

从 RestTemplate 迁移到 WebFlux

我有这个 RestTemplate,我想将其迁移到 WebFlux 客户端: RestTemplaterestTemplate = new RestTemplate(); 字符串 url = "https://www.ecb.europa.eu/stats/eurofxref/eurofxref-daily.xml&...

回答 1 投票 0

当我在代码中使用 thymeleaf 并将标头代码替换为单独的文件时,然后不显示标头选项卡

我正在学习 Spring Boot 并在我的项目中使用 Thymeleaf。当我将标头代码替换为同一文件夹中的单独文件并使用 Thymeleaf 的替换语法、CSS、JS 和 Bootstrap 代码时...

回答 1 投票 0

如何在Spring集成中向流程发送消息?

假设以下流程: 公共 IntegrationFlow sendFlow() { 返回 IntegrationFlow.from(inputChannel()) .handle("某事","someMethod") ...

回答 1 投票 0

无法在我的eclipse中安装spring,不想安装springboot,我需要使用spring core

我正在尝试从eclipse市场在eclipse中安装spring工具套件,但是这个安装过程已完成,但最终无法安装,就像显示的对话框一样,还显示了一些

回答 1 投票 0


我无法获得授权,我需要注册

导入java.util.可选; 导入 org.springframework.data.jpa.repository.JpaRepository; 导入 com.example.secure.models.User; 公共接口 UserRepository 扩展了 JpaRepository import java.util.Optional; import org.springframework.data.jpa.repository.JpaRepository; import com.example.secure.models.User; public interface UserRepository extends JpaRepository<User,Integer>{ Optional<User> findAppUserByUsername(String username); } import com.example.secure.repository.UserRepository; import com.example.secure.models.User; import org.springframework.stereotype.Service; @Service public class UserDetailsServiceImpl implements UserDetailsService { private final UserRepository appUserRepository; public UserDetailsServiceImpl(UserRepository appUserRepository) { this.appUserRepository = appUserRepository; } @Override public UserDetails loadUserByUsername(String username) throws UsernameNotFoundException { User user = appUserRepository .findAppUserByUsername(username) .orElseThrow(() -> new UsernameNotFoundException("Not found")); return org.springframework.security.core.userdetails.User.withUsername(user.getUsername()) .password(user.getPassword()) .roles(user.getAuthority()) .build(); } } @Entity public class User{ @Id @GeneratedValue(strategy = GenerationType.IDENTITY) private Integer id; private String username; private String password; private String authority; //constructors setters and getters } import java.util.Collection; import java.util.List; import org.springframework.security.core.GrantedAuthority; import org.springframework.security.core.authority.SimpleGrantedAuthority; import org.springframework.security.core.userdetails.UserDetails; public class UserAdapter implements UserDetails { private User user; public UserAdapter(User user){ this.user=user; } @Override public Collection<? extends GrantedAuthority> getAuthorities() { return List.of(new SimpleGrantedAuthority(user.getAuthority())); } @Override public String getPassword() { return user.getPassword(); } @Override public String getUsername() { return user.getUsername(); } @Override public boolean isAccountNonExpired() { return true; } @Override public boolean isAccountNonLocked() { return true; } @Override public boolean isCredentialsNonExpired() { return true; } @Override public boolean isEnabled() { return true; } } import com.example.secure.models.User; import com.example.secure.repository.UserRepository; @RestController public class SecurityController { private final UserRepository repo; private final PasswordEncoder passwordEncoder; public SecurityController(UserRepository repo, PasswordEncoder passwordEncoder) { this.repo = repo; this.passwordEncoder = passwordEncoder; } @PostMapping(path = "/register") public String register(@RequestBody RegistrationRequest request) { User user = new User(); System.out.println("Controller started"); user.setUsername(request.username()); user.setPassword(passwordEncoder.encode(request.password())); user.setAuthority(request.authority()); System.out.println(user.toString()); repo.save(user); System.out.println("Controller ended"); return "New user successfully registered"; } @GetMapping(path = "/test") public String test() { return "Access to '/test' granted"; } record RegistrationRequest(String username, String password, String authority) { } } import com.example.secure.service.UserDetailsServiceImpl; @Configuration @EnableWebSecurity(debug = true) public class SecurityConfig { private UserDetailsServiceImpl userDetailsService; public SecurityConfig(UserDetailsServiceImpl userDetailsService) { this.userDetailsService = userDetailsService; } @Bean public SecurityFilterChain securityFilterChain(HttpSecurity http) throws Exception { http .csrf(configurer -> configurer.disable()) .authorizeHttpRequests(auth -> auth .requestMatchers(HttpMethod.GET, "/test").hasAuthority("ROLE_USER") .requestMatchers(HttpMethod.POST, "/register").permitAll() .anyRequest().denyAll()) .httpBasic(Customizer.withDefaults()) .userDetailsService(userDetailsService); return http.build(); } @Bean public PasswordEncoder passwordEncoder() { return new BCryptPasswordEncoder(); } } 以上是我的项目相关的Spring Security代码,当我尝试使用Postman访问端点时,该代码不起作用。当我从 Postman 调用“est”端点时,会从数据库中获取详细信息,但我无法访问该端点。我收到 401 状态代码,如图所示。来自邮递员的 401 状态代码显示响应标头的图像 我从过去两天开始尝试,但无法得到它。 我预计问题是什么以及如何解决。 您有 UserAdapter 类,但实现不完整。请使用以下 UserAdapter 类。 loadUserByUsername():这个抽象方法将返回 UserDetails 类实例,这就是为什么我们必须使用 UserAdapter 类来实现 UserDetails public class UserAdapter implements UserDetails { private String username; private String password; private List<GrantedAuthority> authorities; public UserAdapter(User user){ this.username = user.getUsername(); this.password = user.getPassword(); this.authorities = Stream.of(user.getAuthority().split(",")).map(SimpleGrantedAuthority::new).collect( Collectors.toList()); } @Override public Collection<? extends GrantedAuthority> getAuthorities() { return this.authorities; } @Override public String getPassword() { return this.password; } @Override public String getUsername() { return this.username; } @Override public boolean isAccountNonExpired() { return false; } @Override public boolean isAccountNonLocked() { return false; } @Override public boolean isCredentialsNonExpired() { return false; } @Override public boolean isEnabled() { return false; } } 接下来创建一个单独的类并实现 AuthenticationProvider,因此此实现将帮助提供商管理器识别此客户身份验证 @Component public class CustomizeAuthProvider implements AuthenticationProvider { private final UserDetailsService userDetailsService; public CustomizeAuthProvider(UserDetailsService userDetailsService) { this.userDetailsService = userDetailsService; } @Override public Authentication authenticate(Authentication authentication) throws AuthenticationException { try{ UserDetails userDetails = userDetailsService.loadUserByUsername(authentication.getName()); return new UsernamePasswordAuthenticationToken(userDetails.getUsername(),userDetails.getPassword(),userDetails.getAuthorities()); }catch (UsernameNotFoundException e){ throw new BadCredentialsException("Credentials is invalid"); } } @Override public boolean supports(Class<?> authentication) { return UsernamePasswordAuthenticationToken.class.isAssignableFrom(authentication); } } 替换 UserDetailsServiceImpl 类中的 loadUserByserName 方法 @Override public UserAdapter loadUserByUsername(String username) throws UsernameNotFoundException { Optional<User> user = appUserRepository.findAppUserByUsername(username); return user.map(UserAdapter::new).orElseThrow(()->new UsernameNotFoundException("Not found")); } 还用以下代码更新 securityConfig 方法 @Bean public SecurityFilterChain securityFilterChain(HttpSecurity http) throws Exception { http.csrf(AbstractHttpConfigurer::disable) .authorizeHttpRequests(auth -> auth .requestMatchers(HttpMethod.GET, "/test").hasAuthority("ROLE_USER") .requestMatchers(HttpMethod.POST, "/register").permitAll() .anyRequest().denyAll()) .httpBasic(Customizer.withDefaults()) //here we are providing customer authentication provider .authenticationProvider(authenticationProvider) .userDetailsService(userDetailsService); return http.build(); } 希望这对您有帮助

回答 1 投票 0

Spring-data-mongo 无法使用构造函数实例化 java.util.List

使用 spring-data-mongodb-1.5.4 和 mongodb-driver-3.4.2 我有一个等级酒店 公共类酒店{ 私有字符串名称; 私有 int 价格每晚; 私人地址地址...

回答 3 投票 0

© www.soinside.com 2019 - 2024. All rights reserved.