I'm trying to write REST API in Wildfly server. And, what is default rest context? My project is named eventapp and request mapping is /user. So, I tried localhost:8080/eventapp/user but resposne was 404. Any combination of this two too. My rest controller class:
@RestController
@RequestMapping(value = "/user")
public class UserRest {
@Autowired
private UserService userService;
@RequestMapping(value = "/", method = RequestMethod.GET)
public List<JsonUser> getAllUsers() {
return userService.getAllUsers();
}
}
I'm using maven with Spring. And, the war module which I'm deploying is named rest_services_war. Maybe configuration class is wrong? Annotations I used in conf class: @Configuration and @EnableTransactionManagement. Methods in this class:
@Bean
public LocalSessionFactoryBean sessionFactory() {
LocalSessionFactoryBean sessionFactory = new LocalSessionFactoryBean();
sessionFactory.setDataSource(dataSource());
sessionFactory.setPackagesToScan(new String[] { "com.eventapp.rest.dao_impl" });
sessionFactory.setHibernateProperties(hibernateProperties());
return sessionFactory;
}
@Bean
public DataSource dataSource() {
DriverManagerDataSource dataSource = new DriverManagerDataSource();
dataSource.setDriverClassName("org.postgresql.Driver");
dataSource.setUrl("jdbc:postgresql://localhost:5432/eventapp");
dataSource.setUsername("username");
dataSource.setPassword("password");
return dataSource;
}