spring-mvc

Spring : Add properties file externally

半世苍凉 提交于 2020-01-06 06:24:05
问题 I am working on a Spring-MVC application in which we are preparing to setup application on different servers. As each server can have it's own database related configuration, we are hoping to use an external properties file(outside the war file) which can be read while project is starting. How do I go about this approach? For making it work, I have already moved application initialization code to Java, this way, static XML reading which we had before won't be required. But, we are unsure how

Spring Boot - Handling NoHandlerFoundException

大城市里の小女人 提交于 2020-01-06 05:49:08
问题 Read the Spring Reference Guide on how to handle NoHandlerFoundException and found that Spring sets, by default, throwExceptionIfNoHandlerFound to false . Knowing that, I thought it was a good idea to set this parameter to true . I'm using Spring Boot. Did so: MyConfig.java import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.context.ConfigurableApplicationContext; import org.springframework.web

Spring JPA native query to call store procedrure gives “No converter found capable of converting from type”

一个人想着一个人 提交于 2020-01-06 05:38:08
问题 I'm using Spring JPA and I need to have a native query to call stored procedure. From the result, I need to get only two fields i.e. code and msg. I made a class which contain two field code and msg. It isn't working, this is the error I'm getting: Failed to complete request: org.springframework.core.convert.ConverterNotFoundException: No converter found capable of converting from type [org.springframework.data.jpa.repository.query.AbstractJpaQuery$TupleConverter$TupleBackedMap] to type [com

Speeding up Netflix-Eureka Unregistration not working for Spring Boot

房东的猫 提交于 2020-01-06 05:34:10
问题 I have a eureka server running with the application.yml looking like server: port: 8761 eureka: client: registerWithEureka: false fetch-registry: false server: wait-time-in-ms-when-sync-empty: 5 enable-self-preservation: false and on the client side, I have eureka: instance: prefer-ip-address: true lease-renewal-interval-in-seconds: 1 lease-expiration-duration-in-seconds: 1 client: register-with-eureka: true fetch-registry: true service-url: defaultZone: http://localhost:8761/eureka I

How to create custom web security expression to use in JSP?

∥☆過路亽.° 提交于 2020-01-06 05:07:08
问题 How is it possible to create your own web security expression, so that I'll be able to use it in JSP file like: <sec:authorize access="isOwner()"> some content here </sec:authorize> 回答1: Here is what you need. Follow below to create custom SpEL expression: 1) Create custom subclass of WebSecurityExpressionRoot class. In this subclass create a new method which you will use in expression. For example: public class CustomWebSecurityExpressionRoot extends WebSecurityExpressionRoot { public

Spring MVC 3.1 Using Profiles for environment specific Hibernate settings

南楼画角 提交于 2020-01-06 05:05:21
问题 I am trying to use the bean @Profiles declarations to load specific hibernate settings depending on the app server I deploy to. I have registered a context profile initializer in my web.xml and also implemented the ApplicationContextInitializer interface to perform my app server logic. The problem is that when I deploy my project I'm getting the following error: No matching bean of type [org.hibernate.SessionFactory] found for dependency: expected at least 1 bean which qualifies as autowire

No mapping found for HTTP request with URI [/com.headway/save] in DispatcherServlet with name 'headway'

瘦欲@ 提交于 2020-01-06 04:45:13
问题 web.xml <!DOCTYPE web-app PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN" "http://java.sun.com/dtd/web-app_2_3.dtd" > <web-app> <display-name>Archetype Created Web Application</display-name> <servlet> <servlet-name>headway</servlet-name> <servlet-class> org.springframework.web.servlet.DispatcherServlet </servlet-class> <load-on-startup>1</load-on-startup> </servlet> <servlet-mapping> <servlet-name>headway</servlet-name> <url-pattern>/save</url-pattern> </servlet-mapping> </web

Spring Scheduled annotation how does it work

这一生的挚爱 提交于 2020-01-06 04:13:08
问题 I have created a function in java.That function should run on every day mid night //My function this function is within UpdateService Class @Scheduled(cron = "0 0 0 * * ?") public static void UpdateFn() { try { System.out.println("-----------Background Task Running----------------"); //code to update some data every day System.out.println("-----------Background Task Ending----------------"); } catch (Exception e) { e.printStackTrace(); } } //My xml configuration <task:annotation-driven />

Spring Scheduled annotation how does it work

断了今生、忘了曾经 提交于 2020-01-06 04:13:04
问题 I have created a function in java.That function should run on every day mid night //My function this function is within UpdateService Class @Scheduled(cron = "0 0 0 * * ?") public static void UpdateFn() { try { System.out.println("-----------Background Task Running----------------"); //code to update some data every day System.out.println("-----------Background Task Ending----------------"); } catch (Exception e) { e.printStackTrace(); } } //My xml configuration <task:annotation-driven />

How to browse a file in raml language?

别等时光非礼了梦想. 提交于 2020-01-06 03:58:24
问题 I want to browse a file in RAML like the tool postman: But when I write in RAML language is not support for that: body: multipart/form-data: formParameters: file: description: The file to be uploaded required: true type: file And It doesn't have button "Browse", so I don't know how to attach a file to endpoint: 回答1: This is missing in the API Console as the spec for the file type is clear on the necessity to support file uploads for RAML tooling: file (Applicable only to Form properties)