Spring

Apply spring security only to one page

寵の児 提交于 2021-02-11 15:37:29
问题 I have a typical security configuration: @Override protected void configure(HttpSecurity http) throws Exception { http .authorizeRequests() .antMatchers("/", "/index").permitAll() .anyRequest().authenticated() .and() .formLogin() .loginPage("/login") .permitAll() .and() .logout() .permitAll(); //http.authorizeRequests().antMatchers("/resources/**").permitAll().anyRequest().permitAll(); } Now spring is asking for a login for everything except of the login page... But how could I make it the

springMVC upload file exception

生来就可爱ヽ(ⅴ<●) 提交于 2021-02-11 15:36:34
问题 @ResponseBody @RequestMapping(value="addMultiDisCar",method=RequestMethod.POST) public Map<String, Object> addMultiDisCar(HttpServletRequest request,File uploadFile){ User user=(User) request.getSession().getAttribute("loginUser"); Boolean isAdmin = authorityUtils.checkFunctionURL("distriCarMng.admin", user.getRoleList()); Boolean hasApprove = authorityUtils.checkFunctionURL("distriCarMng.audit", user.getRoleList()); Boolean hasDistri = authorityUtils.checkFunctionURL("distriCarMng

Starting Spring boot REST controller in two ports

若如初见. 提交于 2021-02-11 15:35:21
问题 Is there a way to have two rest controller running on two different ports from one spring boot application ? Say for example Controller_A running in http://localhost:8080 and Controller_B running in http://localhost:9090 in one SpringBoot main Application ? 回答1: One way of doing this is actually creating two application properties; app-A.properties server.port=8080 app-B.properties server.port=9090 And then in your controllers, put annotation like below; @Profile("A") public class ControllerA

springMVC upload file exception

蹲街弑〆低调 提交于 2021-02-11 15:35:21
问题 @ResponseBody @RequestMapping(value="addMultiDisCar",method=RequestMethod.POST) public Map<String, Object> addMultiDisCar(HttpServletRequest request,File uploadFile){ User user=(User) request.getSession().getAttribute("loginUser"); Boolean isAdmin = authorityUtils.checkFunctionURL("distriCarMng.admin", user.getRoleList()); Boolean hasApprove = authorityUtils.checkFunctionURL("distriCarMng.audit", user.getRoleList()); Boolean hasDistri = authorityUtils.checkFunctionURL("distriCarMng

json login on spring security

こ雲淡風輕ζ 提交于 2021-02-11 15:30:38
问题 I'm building a REST back end based on spring and i'm using spring security to secure the requests. But i'm lookin for an issue to login by sending parameters in json rather than defaults parameters sent by the default login page of spring security. I'm working with spring security 4.0.1 and spring 4.1 Any issue please? 回答1: If you're using just username and password, you can simply add a new filter to the stack, akin to the existing UsernamePasswordAuthenticationFilter , that would react to a

json login on spring security

冷暖自知 提交于 2021-02-11 15:30:16
问题 I'm building a REST back end based on spring and i'm using spring security to secure the requests. But i'm lookin for an issue to login by sending parameters in json rather than defaults parameters sent by the default login page of spring security. I'm working with spring security 4.0.1 and spring 4.1 Any issue please? 回答1: If you're using just username and password, you can simply add a new filter to the stack, akin to the existing UsernamePasswordAuthenticationFilter , that would react to a

spring的cglib代理

允我心安 提交于 2021-02-11 15:26:48
1、被代理类Person.java 1 package com.xiaostudy; 2 3 /** 4 * @desc 被代理类 5 * 6 * @author xiaostudy 7 * 8 */ 9 public class Person { 10 11 public void add() { 12 System.out.println("add()>>>>>>>>" ); 13 } 14 15 public void update() { 16 System.out.println("update()>>>>>>>>" ); 17 } 18 19 public void delete() { 20 System.out.println("delete()>>>>>>>>" ); 21 } 22 23 } 2、切面类MyAdvice.java 1 package com.xiaostudy; 2 3 /** 4 * @desc 切面类 5 * 6 * @author xiaostudy 7 * 8 */ 9 public class MyAdvice { 10 11 /** 12 * @desc 植入代理方法的方法 13 */ 14 public void before() { 15 System.out.println("日记开始>>>>>>>>>>>" ); 16 }

Java - Tomcat: Reload context.xml without restarting server

泪湿孤枕 提交于 2021-02-11 15:19:28
问题 I'm using spring mvc and tomcat as a server. I want to be able to change a jndi field that is Autowired(as String): <jee:jndi-lookup id="someMessage" jndi-name="someMessage"/> in one of the my services, that is referenced to conf/context.xml of Tomcat, that looks something like this: <Environment name="someMessage" value="Change this." type="java.lang.String" />. However, when I change the value on context.xml, this change is not reflected on my service managed by spring, unless I restart

@Transactional not working when i throw exception on next line

牧云@^-^@ 提交于 2021-02-11 15:14:34
问题 I don't understand the below behavior: I have a method: @Transactional public void processRejection(final Path path) { try { //some code here } catch (final Exception e) { this.handleException(e)); } } which calls the below which does a saves an entity which doesn't yet exists in the database: void handleException(final Throwable e) { this.filesMonitoringJpaManager.save(someEntityHere); throw new Exception(...) } Now the strange is when I comment the throw new Exception(...) the save works,

Spring boot Webservice / Microservices and scheduling

≯℡__Kan透↙ 提交于 2021-02-11 15:13:19
问题 I am having a spring boot application which exposes REST APIs and also am planning to add a spring boot scheduled task. The purpose of task is to pick up some pending 'reservations' from data store which is momgodb and process it. Now the question is when multiple instances of service running, there is high probability all the nodes will pick up same 'reservation records'. I was looking at mongodb lock for this and was checking updateAndModidy / transactions (in 4.x) of mongodb. Also