Spring boot – Not a managed type

I use Spring boot+JPA and having a problem while starting the service. Caused by: java.lang.IllegalArgumentException: Not an managed type: class com.nervytech.dialer.domain.PhoneSettings at org.hibernate.jpa.internal.metamodel.MetamodelImpl.managedType(MetamodelImpl.java:219) at org.springframework.data.jpa.repository.support.JpaMetamodelEntityInformation.<init>(JpaMetamodelEntityInformation.java:68) at org.springframework.data.jpa.repository.support.JpaEntityInformationSupport.getMetadata(JpaEntityInformationSupport.java:65) at org.springframework.data.jpa.repository.support.JpaRepositoryFactory.getEntityInformation(JpaRepositoryFactory.java:145) at org.springframework.data.jpa.repository.support.JpaRepositoryFactory.getTargetRepository(JpaRepositoryFactory.java:89) at org.springframework.data.jpa.repository.support.JpaRepositoryFactory.getTargetRepository(JpaRepositoryFactory.java:69) at org.springframework.data.repository.core.support.RepositoryFactorySupport.getRepository(RepositoryFactorySupport.java:177) at org.springframework.data.repository.core.support.RepositoryFactoryBeanSupport.initAndReturn(RepositoryFactoryBeanSupport.java:239) at org.springframework.data.repository.core.support.RepositoryFactoryBeanSupport.afterPropertiesSet(RepositoryFactoryBeanSupport.java:225) at org.springframework.data.jpa.repository.support.JpaRepositoryFactoryBean.afterPropertiesSet(JpaRepositoryFactoryBean.java:92) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1625) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1562) Here is the Application.java file, @Configuration @ComponentScan @EnableAutoConfiguration(exclude = { … Read more

How to handle static content in Spring MVC?

I am developing a webapp using Spring MVC 3 and have the DispatcherServlet catching all requests to “https://stackoverflow.com/” like so (web.xml): <servlet> <servlet-name>app</servlet-name> <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class> </servlet> <servlet-mapping> <servlet-name>app</servlet-name> <url-pattern>/</url-pattern> </servlet-mapping> Now this works as advertised, however how can I handle static content? Previously, before using RESTful URLs, I would have caught all *.html for example and … Read more

What is the difference between ApplicationContext and WebApplicationContext in Spring MVC?

What is the difference between Application Context and Web Application Context? I am aware that WebApplicationContext is used for Spring MVC architecture oriented applications? I want to know what is the use of ApplicationContext in MVC applications? And what kind of beans are defined in ApplicationContext? 5 Answers 5

When use ResponseEntity and @RestController for Spring RESTful applications

I am working with Spring Framework 4.0.7, together with MVC and Rest I can work in peace with: @Controller ResponseEntity<T> For example: @Controller @RequestMapping(“/person”) @Profile(“responseentity”) public class PersonRestResponseEntityController { With the method (just to create) @RequestMapping(value=”https://stackoverflow.com/”, method=RequestMethod.POST) public ResponseEntity<Void> createPerson(@RequestBody Person person, UriComponentsBuilder ucb){ logger.info(“PersonRestResponseEntityController – createPerson”); if(person==null) logger.error(“person is null!!!”); else logger.info(“{}”, person.toString()); personMapRepository.savePerson(person); … Read more

Spring MVC – How to get all request params in a map in Spring controller?

Sample URL: ../search/?attr1=value1&attr2=value2&attr4=value4 I do not know the names of attr1, att2, and attr4. I would like to be able to do something like that (or similar, don’t care, just as long as I have access to the Map of request param name -> value: @RequestMapping(value = “/search/{parameters}”, method = RequestMethod.GET) public void search(HttpServletRequest request, … Read more

@RequestParam in Spring MVC handling optional parameters

Is it possible for a Spring controller to handle both kind of requests? 1) http://localhost:8080/submit/id/ID123432?logout=true 2) http://localhost:8080/submit/id/ID123432?name=sam&password=543432 If I define a single controller of the kind: @RequestMapping (value = “/submit/id/{id}”, method = RequestMethod.GET, produces=”text/xml”) public String showLoginWindow(@PathVariable(“id”) String id, @RequestParam(value = “logout”, required = false) String logout, @RequestParam(“name”) String username, @RequestParam(“password”) String password, @ModelAttribute(“submitModel”) SubmitModel … Read more

Add context path to Spring Boot application

I am trying to set a Spring Boot applications context root programmatically. The reason for the context root is we want the app to be accessed from localhost:port/{app_name} and have all the controller paths append to it. Here is the application configuration file for the web-app. @Configuration public class ApplicationConfiguration { Logger logger = LoggerFactory.getLogger(ApplicationConfiguration.class); … Read more