spring 相关问题

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

如何为Spring ControlFlowPointcut指定多个方法?

读一本《临春》来了个例子 切入点 pc = new ControlFlowPointcut(ControlFlowDemo.class, "test"); 很清楚它是如何工作的,但问题是 - 是否可能......

回答 2 投票 0

如何为ControlFlowPointcut构造函数指定几个方法?

读一本《临春》来了个例子 切入点 pc = new ControlFlowPointcut(ControlFlowDemo.class, "test"); 很清楚它是如何工作的,但问题是 - 是否可能......

回答 2 投票 0

如何用三种语言向机器人、网站指示?

我正在制作三种语言(ru、en、he)的信息娱乐平台,针对以色列市场(多语言人群)。也许在未来 - 社交网络。如何向机器人指示(比如G...

回答 1 投票 0

Spring Security 基本身份验证:来自 Postman 的 JSESSIONID cookie 未授权后续请求(401 错误)

在我的 Spring Security 3.1.0 应用程序中,我使用 Postman 成功访问了安全端点。已授予基本身份验证(用户名和密码)身份验证,允许我查看端点...

回答 1 投票 0

基于请求匹配器的Spring security oauth2Login

Spring Security 新手,我想为某些页面应用不同的领域(领域 1)登录,并为其余页面(领域 2)应用不同的登录: 尝试过: @豆 @Order(Ordered.HIGHEST_PRECEDEN...

回答 1 投票 0

没有“org.springframework.core.task.TaskExecutor”类型的合格bean可用

当我运行 Spring 应用程序时,我收到 NoUniqueBeanDefinitionException。 之后的应用程序运行良好,但我担心它可能会在将来引起意外的错误。 堆栈跟踪: 16:49:18.003 [

回答 1 投票 0

Spring websocket 连接在 30 秒后被 Spring Cloud Gateway 关闭

我的应用程序是一个微服务应用程序。我正在使用 Spring Web 套接字向前端发送通知。在我的应用程序中,我有一个网关服务将 HTTP 请求路由到相关...

回答 1 投票 0

Log4j2 RoutingAppender 与跨多个线程的 ListAppender

(这是我最初问题的后续问题:Log4j2 Custom Appender in Maven Surefire: possible to Reuse Across Threads?) 我正在尝试对来自 Log4j2 的任何日志记录的输出进行单元测试...

回答 1 投票 0

升级到 Spring 3 后无法到达 Spring @RestController 公共入口点

我们已经使用 JDK 17 和 Spring-boot 最新版本升级了 Spring-boot Java 应用程序。这还包括升级我们所有的外部依赖项以清理任何pote...

回答 1 投票 0

如何使用 Spring Cloud Contract Verifier 跳过测试生成 Maven 目标?

我想测试一个服务 Consumer,它使用 FeignClient 来调用我拥有的另一个服务 Producer。为了存根所调用的服务,我使用 spring-cloud-contract-verifier 来生产...

回答 3 投票 0

如何记录 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

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