Error 'dispatcherServlet' when consuming web service Rest with Spring

0

Good morning, I have been trying to solve this problem for some time, the problem I have is that I developed an application using Spring, in it I have a web service Rest which at the time of trying to consume I get the following error:

Initializing Spring FrameworkServlet 'dispatcherServlet'

And from the browser it gives me the following message;

Whitelabel Error Page

This application has not explicit mapping for / error, so you are seeing this as a fallback.

Below I detail my system files:

WebServiceBack.java

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.annotation.ComponentScan;

@SpringBootApplication
@ComponentScan(basePackages= {"municipalidad.domain"})
public class WebServiceBack {

    public static void main(String[] args) {
        SpringApplication.run(WebServiceBack.class, args);
    }


}

ConfigApp.java

@Configuration
@EnableTransactionManagement
public class ConfigApp {

    @Bean
    public DataSource dataSource(){
       DriverManagerDataSource dataSource = new DriverManagerDataSource();
       dataSource.setDriverClassName("oracle.jdbc.OracleDriver");
       dataSource.setUrl("jdbc:oracle:thin:@//192.168.48.25:1521/db");
       dataSource.setUsername( "user" );
       dataSource.setPassword( "pass" );
       return dataSource;
    }


    @Bean
    public LocalContainerEntityManagerFactoryBean entityManagerFactory() throws SQLException {
       LocalContainerEntityManagerFactoryBean em = new LocalContainerEntityManagerFactoryBean();
       em.setDataSource(dataSource());
       em.setPackagesToScan(new String[] { "org.baeldung.persistence.model" });

       JpaVendorAdapter vendorAdapter = new HibernateJpaVendorAdapter();
       em.setJpaVendorAdapter(vendorAdapter);
       em.setJpaProperties(additionalProperties());

       return em;
    }


    @Bean
    public PlatformTransactionManager transactionManager(EntityManagerFactory emf){
       JpaTransactionManager transactionManager = new JpaTransactionManager();
       transactionManager.setEntityManagerFactory(emf);

       return transactionManager;
    }

    @Bean
    public PersistenceExceptionTranslationPostProcessor exceptionTranslation(){
       return new PersistenceExceptionTranslationPostProcessor();
    }

    Properties additionalProperties() {
       Properties properties = new Properties();
       properties.setProperty("hibernate.hbm2ddl.auto", "create-drop");
       properties.setProperty("hibernate.dialect", "org.hibernate.dialect.Oracle10gDialect");
       return properties;
    }
}

WebConfig.java

@Configuration
public class WebConfig extends WebMvcConfigurerAdapter{
//    @Bean
    public void addResourceHandlers(final ResourceHandlerRegistry registry) {
        registry.addResourceHandler("/*").addResourceLocations("/");
    }

}

PadronResource.java

@RestController
@RequestMapping("/api")
public class PadronResource {

    public final PadronService padronService;

    public PadronResource(PadronService padronService) {
        super();
        this.padronService = padronService;
    }



    @GetMapping("/padron/{cuit}")
    public @ResponseBody ResponseEntity<Padron> getPadron(@PathVariable Long cuit) {
        Padron retorno = new Padron();
        retorno = padronService.getPersona(cuit);
        return new ResponseEntity(retorno, HttpStatus.OK);
    }

}

pom.xml

<dependencies>
    <!-- APP -->
    <!-- https://mvnrepository.com/artifact/org.springframework.boot/spring-boot -->
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot</artifactId>
        <version>1.5.6.RELEASE</version>
    </dependency>



    <!-- DOMAIN -->
    <!-- https://mvnrepository.com/artifact/org.hibernate/hibernate-entitymanager -->
    <dependency>
        <groupId>org.hibernate</groupId>
        <artifactId>hibernate-entitymanager</artifactId>
        <version>5.2.10.Final</version>
    </dependency>


    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-tomcat</artifactId>
        <version>1.5.6.RELEASE</version>
    </dependency>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-web</artifactId>
        <version>1.5.6.RELEASE</version>
    </dependency>

    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-data-jpa</artifactId>
        <version>1.5.6.RELEASE</version>
    </dependency>

    <!-- REST -->

    <!-- https://mvnrepository.com/artifact/oracle/ojdbc6 -->
    <dependency>
        <groupId>com.oracle</groupId>
        <artifactId>ojdbc6</artifactId>
        <version>11.2.0.3</version>
    </dependency>



  </dependencies>

In the browser to consume I put:

link

    
asked by NicoGuevaraAtuq 20.09.2017 в 15:34
source

0 answers