@Override public void afterPropertiesSet() throws Exception { if(defaultAuthenticationEntryPoint==null){ LoginUrlAuthenticationEntryPoint entryPoint = new LoginUrlAuthenticationEntryPoint(securityConfig.getLoginUrl()); entryPoint.setForceHttps(forceHttps); entryPoint.setPortMapper(new PortMapperImpl(){ public Integer lookupHttpsPort(Integer httpPort) { Integer port = super.lookupHttpsPort(httpPort); return port==null?httpsPort:port; } }); PropertyAccessorFactory.forDirectFieldAccess(entryPoint).setPropertyValue("redirectStrategy.contextRelative", contextRelative); this.defaultAuthenticationEntryPoint = entryPoint; } }