无法解析其余

时间:2018-03-26 10:45:19

标签: java spring hibernate spring-boot embedded-tomcat-8

我想制作Spring Boot服务,在这里我可以从SQL服务器数据库中获取所有表值或具有适当id地址的值,因此我使用过:

  • CrudReposiotry
  • 带服务器配置的application.properties
  • RestController
  • SpringBootApplication及其嵌入式Tomcat

这是我的存储库界面:

import org.springframework.data.repository.CrudRepository;
import org.springframework.data.rest.core.annotation.RepositoryRestResource;
import org.springframework.stereotype.Repository;

import  ge.sda.spring.HoliDay.Data.*;

@Repository
public interface DayRepository extends CrudRepository<DayEntity, Integer> {

}

这是我的服务:

@Service
public class CalculateHoliDayService {
@Autowired
public DayRepository repository;

public DayEntity getDayByID(Integer  Id) {
    return repository.findOne(Id);
}

public List<DayEntity> getAllDay(){
    List<DayEntity>docs=new ArrayList<DayEntity>();
      repository.findAll().forEach(docs::add);
        return  docs;
}

}

这是我的控制器:

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import ge.sda.spring.HoliDay.Data.DayEntity;
import ge.sda.spring.HoliDayService.CalculateHoliDayService ;


   @RestController
   @RequestMapping("/profile/rest") 
    public class DayController {

    @Autowired
    public  CalculateHoliDayService  DayService;

    @RequestMapping(value="/all")
    public List<DayEntity> getAllDocument() {
        return DayService.getAllDay();
    }
    @RequestMapping(value="/{id}")
    public DayEntity getDocument(@PathVariable Integer Id) {
        return DayService.getHoliDayByID(Id);
    }
    }

这是application.properties:

# Server server.port=9010 spring.datasource.url=jdbc:sqlserver://url;    servername=server;databaseName=Days
spring.datasource.username=user spring.datasource.password=*****
spring.datasource.driverClassName=com.microsoft.sqlserver.jdbc.SQLServerDriver
spring.jpa.show-sql=true
spring.jpa.properties.hibernate.dialect=org.hibernate.dialect.SQLServerDialect
spring.jpa.properties.hibernate.globally_quoted_identifiers=true
# Logging logging.level.com.bytestree.restful=DEBUG

申请类:

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

这是我的pom:

 <properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <maven.compiler.source>1.8</maven.compiler.source>
        <maven.compiler.target>1.8</maven.compiler.target>
    </properties>
  <parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>1.5.6.RELEASE</version>
    </parent>
 <dependencies>
  <dependency>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-data-rest</artifactId>
</dependency>
<dependency>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-data-jpa</artifactId>
</dependency>

        <dependency>
            <groupId>com.microsoft.sqlserver</groupId>
            <artifactId>mssql-jdbc</artifactId>
        </dependency>
         <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-web</artifactId>
    </dependency>
    <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-webmvc</artifactId>
    </dependency>
    <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-jdbc</artifactId>
    </dependency>
</dependencies>

<build>
        <plugins>
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
                <configuration>
          <jvmArguments>
            -Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=5005
          </jvmArguments>
        </configuration>
            </plugin>
        </plugins>
    </build>

但是当我启动spring boot应用程序并尝试此URL时: http://localhost:9010/profile/rest/2

我收到了这个错误:

enter image description here

  

2018-03-26 15:44:02.416 ERROR 612 --- [nio-9010-exec-6]   o.a.c.c.C。[。[。[/]。[dispatcherServlet]:Servlet.service()for   在path []的上下文中的servlet [dispatcherServlet]引发了异常   [请求处理失败;嵌套异常是   java.lang.IllegalArgumentException:无法解析存储库   所有。的元数据。有根本原因

     

java.lang.IllegalArgumentException:无法解析存储库   所有人的元数据。在   org.springframework.data.rest.webmvc.config.ResourceMetadataHandlerMethodArgumentResolver.resolveArgument(ResourceMetadataHandlerMethodArgumentResolver.java:97)   〜[spring-data-rest-webmvc-2.6.6.RELEASE.jar:na] at   org.springframework.data.rest.webmvc.config.RootResourceInformationHandlerMethodArgumentResolver.resolveArgument(RootResourceInformationHandlerMethodArgumentResolver.java:83)   〜[spring-data-rest-webmvc-2.6.6.RELEASE.jar:na] at   org.springframework.data.rest.webmvc.config.RootResourceInformationHandlerMethodArgumentResolver.resolveArgument(RootResourceInformationHandlerMethodArgumentResolver.java:40)   〜[spring-data-rest-webmvc-2.6.6.RELEASE.jar:na] at   org.springframework.web.method.support.HandlerMethodArgumentResolverComposite.resolveArgument(HandlerMethodArgumentResolverComposite.java:121)   〜[spring-web-4.3.10.RELEASE.jar:4.3.10.RELEASE] at   org.springframework.web.method.support.InvocableHandlerMethod.getMethodArgumentValues(InvocableHandlerMethod.java:158)   〜[spring-web-4.3.10.RELEASE.jar:4.3.10.RELEASE] at   org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:128)   〜[spring-web-4.3.10.RELEASE.jar:4.3.10.RELEASE] at   org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:97)   〜[spring-webmvc-4.3.10.RELEASE.jar:4.3.10.RELEASE] at   org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandlerMethod(RequestMappingHandlerAdapter.java:827)   〜[spring-webmvc-4.3.10.RELEASE.jar:4.3.10.RELEASE] at   org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:738)   〜[spring-webmvc-4.3.10.RELEASE.jar:4.3.10.RELEASE] at   org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:85)   〜[spring-webmvc-4.3.10.RELEASE.jar:4.3.10.RELEASE] at   org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:967)   〜[spring-webmvc-4.3.10.RELEASE.jar:4.3.10.RELEASE] at   org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:901)   〜[spring-webmvc-4.3.10.RELEASE.jar:4.3.10.RELEASE] at   org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:970)   〜[spring-webmvc-4.3.10.RELEASE.jar:4.3.10.RELEASE] at   org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:861)   〜[spring-webmvc-4.3.10.RELEASE.jar:4.3.10.RELEASE] at   javax.servlet.http.HttpServlet.service(HttpServlet.java:635)   〜[tomcat-embed-core-8.5.16.jar:8.5.16] at   org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:846)   〜[spring-webmvc-4.3.10.RELEASE.jar:4.3.10.RELEASE] at   javax.servlet.http.HttpServlet.service(HttpServlet.java:742)   〜[tomcat-embed-core-8.5.16.jar:8.5.16] at   org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:231)   〜[tomcat-embed-core-8.5.16.jar:8.5.16] at   org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)   〜[tomcat-embed-core-8.5.16.jar:8.5.16] at   org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)   〜[tomcat-embed-websocket-8.5.16.jar:8.5.16] at   org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)   〜[tomcat-embed-core-8.5.16.jar:8.5.16] at   org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)   〜[tomcat-embed-core-8.5.16.jar:8.5.16] at   org.springframework.web.filter.RequestContextFilter.doFilterInternal(RequestContextFilter.java:99)   〜[spring-web-4.3.10.RELEASE.jar:4.3.10.RELEASE] at   org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)   〜[spring-web-4.3.10.RELEASE.jar:4.3.10.RELEASE] at   org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)   〜[tomcat-embed-core-8.5.16.jar:8.5.16] at   org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)   〜[tomcat-embed-core-8.5.16.jar:8.5.16] at   org.springframework.web.filter.HttpPutFormContentFilter.doFilterInternal(HttpPutFormContentFilter.java:105)   〜[spring-web-4.3.10.RELEASE.jar:4.3.10.RELEASE] at   org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)   〜[spring-web-4.3.10.RELEASE.jar:4.3.10.RELEASE] at   org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)   〜[tomcat-embed-core-8.5.16.jar:8.5.16] at   org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)   〜[tomcat-embed-core-8.5.16.jar:8.5.16] at   org.springframework.web.filter.HiddenHttpMethodFilter.doFilterInternal(HiddenHttpMethodFilter.java:81)   〜[spring-web-4.3.10.RELEASE.jar:4.3.10.RELEASE] at   org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)   〜[spring-web-4.3.10.RELEASE.jar:4.3.10.RELEASE] at   org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)   〜[tomcat-embed-core-8.5.16.jar:8.5.16] at   org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)   〜[tomcat-embed-core-8.5.16.jar:8.5.16] at   org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:197)   〜[spring-web-4.3.10.RELEASE.jar:4.3.10.RELEASE] at   org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)   〜[spring-web-4.3.10.RELEASE.jar:4.3.10.RELEASE] at   org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)   〜[tomcat-embed-core-8.5.16.jar:8.5.16] at   org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)   〜[tomcat-embed-core-8.5.16.jar:8.5.16] at   org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:198)   〜[tomcat-embed-core-8.5.16.jar:8.5.16] at   org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:96)   [tomcat-embed-core-8.5.16.jar:8.5.16] at   org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:478)   [tomcat-embed-core-8.5.16.jar:8.5.16] at   org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:140)   [tomcat-embed-core-8.5.16.jar:8.5.16] at   org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:80)   [tomcat-embed-core-8.5.16.jar:8.5.16] at   org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:87)   [tomcat-embed-core-8.5.16.jar:8.5.16] at   org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:342)   [tomcat-embed-core-8.5.16.jar:8.5.16] at   org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:799)   [tomcat-embed-core-8.5.16.jar:8.5.16] at   org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:66)   [tomcat-embed-core-8.5.16.jar:8.5.16] at   org.apache.coyote.AbstractProtocol $ ConnectionHandler.process(AbstractProtocol.java:868)   [tomcat-embed-core-8.5.16.jar:8.5.16] at   org.apache.tomcat.util.net.NioEndpoint $ SocketProcessor.doRun(NioEndpoint.java:1455)   [tomcat-embed-core-8.5.16.jar:8.5.16] at   org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49)   [tomcat-embed-core-8.5.16.jar:8.5.16] at   java.util.concurrent.ThreadPoolExecutor.runWorker(未知来源)   [na:1.8.0_151] at   java.util.concurrent.ThreadPoolExecutor $ Worker.run(未知来源)   [na:1.8.0_151] at   org.apache.tomcat.util.threads.TaskThread $ WrappingRunnable.run(TaskThread.java:61)   java.lang.Thread.run上的[tomcat-embed-core-8.5.16.jar:8.5.16](未知   来源)[na:1.8.0_151]

我应该更改什么才能使这项服务有效?

0 个答案:

没有答案