0


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;
    }
thehespe
  • 97
  • 1
  • 12
  • Try `localhost:8080/rest_services_war/user` - consider renaming your war module to `eventapp.war` – Elliott Frisch Feb 18 '18 at 18:29
  • Also it's `/user/` not `/user` based on your mapping. – Kayaman Feb 18 '18 at 18:34
  • localhost:8080/rest_services_war/user also return Not Found. With / in the end also. :) But /rest_services_war/user/ return simply *Not Found* and /eventapp/user/ *404 - Not Found*, so there is a small difference. – thehespe Feb 18 '18 at 18:46

0 Answers0