Skip to content

Tag: spring-mvc

How to get user id with Spring MVC?

I using the POST method for add Item to the database with Spring MVC. But each Item has field userId, it FOREIGN KEY to users table. Need to know user’s id for this. I using Spring security for auth. May be there is a possibility get current user’s id with ServletContext or HttpSession, may be spring security save user’s id

Maven not found in Jenkins

I am running my Maven/Spring project in Jenkins (just testing it out, first time) using the shell script option with: mvn spring-boot:run I get the build error: /Users/Shared/Jenkins/tmp/ line 2: mvn: command not found How can I fix this? Its a Spring-boot app. It works fine when I run mvn spring-boot:run via command line. Answer Try this, Navigate to Manage

Spring Security UserDetailsService must be set Error

Just i dont understand, why customUserDetailsService doesn’t autowire There are 2 classes i use ================= And there is stackTrace Please explain me, how it’s possible. These classes have the same package, i included this package @ComponentScan annotation. And spring still complains that he cant find @Service Component. There is something easy, but i cant get it. Please help. Answer I

Clarify a situation with a cleaning Spring Prototype-beans from memory

I would like to understand whether I should clean prototype-beans from memory manually by myself. In the Spring documentation you can see: “The client code must clean up prototype-scoped objects and release expensive resources that the prototype bean(s) are holding.” So from this it seems that you should clean prototype-beans by yourself. However. I’m using VisualVM memory profiler. I have

Could not exec java with Spring+Maven exit code 1

I am new to Spring/Maven, and am following this tutorial: Serving Web Content with Spring MVC. Everytime I run mvn spring-boot:run, I get this error: Failed to execute goal org.springframework.boot:spring-boot-maven-plugin:1.5.2.RELEASE:run (default-cli) on project gs-serving-web-content: Could not exec java: Application finished with exit code: 1 -> I tried to add classpath, tried to run mvn install clean spring-boot:run, did a lot

Spring Security – 405 Request Method ‘POST’ Not Supported

I have implemented Spring Security to my project, but I am getting status 405 when I try to log in. I have already added csrf token in the form. This is the error I am getting when I send username and password: HTTP Status 405 – Request method ‘POST’ not supported Spring version: 4.0.2.RELEASED Security Configuration: Controller: Almost every topic

What causes “java.lang.IllegalStateException: Neither BindingResult nor plain target object for bean name ‘command’ available as request attribute”?

This is meant to be an extensive canonical question & answer post for these types of questions. I’m trying to write a Spring MVC web application where users can add movie names to an in-memory collection. It’s configured like so and There’s a single @Controller class in the com.example package WEB-INF/jsps/index.jsp contains The application is configured with context path /Example.