запрос картографирования в весенний отдых - PullRequest
0 голосов
/ 19 октября 2018

Может ли кто-нибудь поддержать меня, я использую STS, попробуйте сделать простой веб-сервис отдыха.tomcat не показывает никаких ошибок, но я не могу сохранить данные через веб-сервис. Я использую этот URL http://localhost:8080/auth/authenticateUser в postman.postman показывает ошибку

HTTP Status 404 - Not Foundh1 {font-family:Tahoma, Arial, без засечек; цвет: белый; цвет фона: # 525D76; размер шрифта: 22px;} h2 {font-family: Tahoma, Arial, без засечек; цвет: белый; цвет фона: # 525D76; размер шрифта: 16px;} h3 {семейство шрифтов: Tahoma, Arial, без засечек; цвет: белый; цвет фона: # 525D76; размер шрифта: 14px;} body {семейство шрифтов: Tahoma, Arial,sans-serif; цвет: черный; цвет фона: белый;} b {семейство шрифтов: Tahoma, Arial, sans-serif; цвет: белый; цвет фона: # 525D76;} p {семейство шрифтов: Tahoma, Arial, без засечек; фон: белый; цвет: черный; размер шрифта: 12px;} a {цвет: черный;} a.name {цвет: черный;} .line {высота: 1px; цвет фона: # 525D76;border: none;}

HTTP-статус 404 - не найден

Тип Отчет о состоянии

Сообщение / auth / authenticateUser

Описание Исходный сервер не нашелтекущее представление для целевого ресурса или не хочет раскрывать, что он существует.

Apache Tomcat / 9.0.7

код контроллера остатка равен

package com.innovent.RBAuth.rest;

import java.awt.print.Printable;

import org.json.simple.JSONObject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.http.MediaType;

import com.RBAuth.DTO.UserDTO;
import com.google.gson.Gson;
import com.innovent.RBAuth.service.RBAuthService;

@RestController
@RequestMapping(value="/auth", method=RequestMethod.POST,
                consumes=MediaType.APPLICATION_FORM_URLENCODED_VALUE + ";charset=UTF-8",
                produces=MediaType.TEXT_PLAIN_VALUE + ";charset=UTF-8")
public class RBAuthResourceAPI {

    @Autowired
    RBAuthService service;

    @RequestMapping(value="/authenticateUser")
    public String authenticateUser(@RequestParam("email") String email, @RequestParam("name") String name) throws Exception {



        JSONObject referenceObject = new JSONObject();
        Gson gson = new Gson();


        // Here you have to call the service methods and authenticate the user accordingly
        UserDTO user = new UserDTO();

        service.saveUser(user);
        System.out.println(user);
        return gson.toJson(user);

    }


}

web.xml is

<?xml version="1.0" encoding="ISO-8859-1"?>
<!-- <web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xmlns="http://java.sun.com/xml/ns/javaee"
         xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
                             http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
         id="WebApp_ID" version="2.5"> -->
         <web-app xmlns="http://java.sun.com/xml/ns/javaee"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://java.sun.com/xml/ns/javaee 
          http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"
    version="3.0">


    <display-name>Event Managemet Application</display-name>



    <!--
        - Servlet that dispatches request to registered handlers (Controller implementations).
    -->
    <servlet>
        <servlet-name>spring</servlet-name>
        <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
        <load-on-startup>1</load-on-startup>
    </servlet>

    <servlet-mapping>
        <servlet-name>spring</servlet-name>
        <url-pattern>/</url-pattern>
    </servlet-mapping>
    <!--  registers Spring for soap service  -->
    <listener>
        <listener-class>
            org.springframework.web.context.ContextLoaderListener
        </listener-class>
    </listener>
    <!--  these are for JAX-WS  -->
    <servlet>
        <servlet-name>jaxws-servlet</servlet-name>
        <servlet-class>
            com.sun.xml.ws.transport.http.servlet.WSSpringServlet
        </servlet-class>
    </servlet>
    <servlet-mapping>
        <servlet-name>jaxws-servlet</servlet-name>
        <url-pattern>/auth</url-pattern>
    </servlet-mapping>

spring servlet.xml is

<?xml version="1.0" encoding="UTF-8"?>

<beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xmlns:mvc="http://www.springframework.org/schema/mvc" xmlns:context="http://www.springframework.org/schema/context"
    xmlns:tx="http://www.springframework.org/schema/tx"
    xsi:schemaLocation="http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc.xsd
        http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
        http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd
        http://www.springframework.org/schema/tx 
        http://www.springframework.org/schema/tx/spring-tx.xsd">

    <!-- to make annotations work -->
    <context:component-scan base-package="com.innovent" />
    <mvc:annotation-driven />
    <tx:annotation-driven />
    <tx:jta-transaction-manager  />

    <!-- Property files  -->
<!--     <context:property-placeholder location="/WEB-INF/,
                                            /WEB-INF/"/>
 -->

    <!-- Datasource -->
    <bean id="dataSource" class="org.springframework.jdbc.datasource.DriverManagerDataSource">
      <property name="driverClassName" value="org.postgresql.Driver" />
      <property name="url" value="jdbc:postgresql://localhost:5432/Events" />
      <property name="username" value="postgres" />
      <property name="password" value="sa4067673" />
   </bean>

    <!-- This produces a container-managed EntityManagerFactory; 
         rather than application-managed EntityManagerFactory as in case of LocalEntityManagerFactoryBean-->
    <bean id="entityManagerFactoryBean" class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean">
      <property name="dataSource" ref="dataSource" />
      <!-- This makes /META-INF/persistence.xml is no longer necessary -->
      <property name="packagesToScan" value="ae.dubaipolice.model, ae.dubaipolice.common.model" />
      <!-- JpaVendorAdapter implementation for Hibernate EntityManager.
           Exposes Hibernate's persistence provider and EntityManager extension interface -->
      <property name="jpaVendorAdapter">
          <bean class="org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter">
              <property name="generateDdl" value="true" />
              <property name="showSql" value="true" />
          </bean>
      </property>
      <property name="jpaProperties">
         <props>
            <prop key="hibernate.hbm2ddl.auto">validate</prop>
            <prop key="hibernate.dialect">org.hibernate.dialect.MySQL5Dialect</prop>
         </props>
      </property>
    </bean>

   <!-- This transaction manager is appropriate for applications that use a single JPA EntityManagerFactory for transactional data access. 
        JTA (usually through JtaTransactionManager) is necessary for accessing multiple transactional resources within the same transaction. -->
    <bean id="transactionManager" class="org.springframework.orm.jpa.JpaTransactionManager">
      <property name="entityManagerFactory" ref="entityManagerFactoryBean" />
      <property name="dataSource" ref="dataSource"></property>
    </bean>

    <!-- <bean id="transactionManager" class="org.springframework.transaction.jta.JtaTransactionManager" /> -->

</beans>
...