2016-05-05 29 views
0

私はSpringとHibernateを使ってJava Webアプリケーションを構築しようとしています。そして、Tomcatで起動しようとするとweb.xmlに関するエラーが発生します。私はweb.xmlに見てみると、私はこの取得:サーブレットにマッピングがあり、サーブレットが見つかりません

Connected to server 
[2016-05-05 08:40:35,438] Artifact tryHW-web:war exploded: Artifact is being deployed, please wait... 
05-May-2016 20:40:39.916 WARNING [RMI TCP Connection(3)-127.0.0.1] org.apache.tomcat.dbcp.dbcp2.BasicDataSourceFactory.getObjectInstance Name = mpp Property maxActive is not used in DBCP2, use maxTotal instead. maxTotal default value is 8. You have set value of "100" for "maxActive" property, which is being ignored. 
05-May-2016 20:40:39.917 WARNING [RMI TCP Connection(3)-127.0.0.1] org.apache.tomcat.dbcp.dbcp2.BasicDataSourceFactory.getObjectInstance Name = mpp Property maxWait is not used in DBCP2 , use maxWaitMillis instead. maxWaitMillis default value is -1. You have set value of "10000" for "maxWait" property, which is being ignored. 
05-May-2016 20:40:40.126 INFO [RMI TCP Connection(3)-127.0.0.1] org.apache.jasper.servlet.TldScanner.scanJars At least one JAR was scanned for TLDs yet contained no TLDs. Enable debug logging for this logger for a complete list of JARs that were scanned but no TLDs were found in them. Skipping unneeded JARs during scanning can improve startup time and JSP compilation time. 
2016-05-05T20:40:43,667 WARN [RMI TCP Connection(3)-127.0.0.1]: nnotationConfigWebApplicationContext - Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'clientServiceImpl': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: private shop.tryHW.core.repository.ClientRepository shop.tryHW.core.service.ClientServiceImpl.clientRepository; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type [shop.tryHW.core.repository.ClientRepository] found for dependency: expected at least 1 bean which qualifies as autowire candidate for this dependency. Dependency annotations: {@org.springframework.beans.factory.annotation.Autowired(required=true)} 
2016-05-05T20:40:43,729 ERROR [RMI TCP Connection(3)-127.0.0.1]: ContextLoader      - Context initialization failed 
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'clientServiceImpl': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: private shop.tryHW.core.repository.ClientRepository shop.tryHW.core.service.ClientServiceImpl.clientRepository; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type [shop.tryHW.core.repository.ClientRepository] found for dependency: expected at least 1 bean which qualifies as autowire candidate for this dependency. Dependency annotations: {@org.springframework.beans.factory.annotation.Autowired(required=true)} 
    at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessPropertyValues(AutowiredAnnotationBeanPostProcessor.java:334) ~[spring-beans-4.2.5.RELEASE.jar:4.2.5.RELEASE] 
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1214) ~[spring-beans-4.2.5.RELEASE.jar:4.2.5.RELEASE] 
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:543) ~[spring-beans-4.2.5.RELEASE.jar:4.2.5.RELEASE] 
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:482) ~[spring-beans-4.2.5.RELEASE.jar:4.2.5.RELEASE] 
    at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:306) ~[spring-beans-4.2.5.RELEASE.jar:4.2.5.RELEASE] 
    at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230) ~[spring-beans-4.2.5.RELEASE.jar:4.2.5.RELEASE] 
    at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:302) ~[spring-beans-4.2.5.RELEASE.jar:4.2.5.RELEASE] 
    at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:197) ~[spring-beans-4.2.5.RELEASE.jar:4.2.5.RELEASE] 
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:772) ~[spring-beans-4.2.5.RELEASE.jar:4.2.5.RELEASE] 
    at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:839) ~[spring-context-4.2.5.RELEASE.jar:4.2.5.RELEASE] 
    at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:538) ~[spring-context-4.2.5.RELEASE.jar:4.2.5.RELEASE] 
    at org.springframework.web.context.ContextLoader.configureAndRefreshWebApplicationContext(ContextLoader.java:444) ~[spring-web-4.2.5.RELEASE.jar:4.2.5.RELEASE] 
    at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:326) [spring-web-4.2.5.RELEASE.jar:4.2.5.RELEASE] 
    at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:107) [spring-web-4.2.5.RELEASE.jar:4.2.5.RELEASE] 
    at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4732) [catalina.jar:9.0.0.M4] 
    at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5194) [catalina.jar:9.0.0.M4] 
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:152) [catalina.jar:9.0.0.M4] 
    at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:726) [catalina.jar:9.0.0.M4] 
    at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:702) [catalina.jar:9.0.0.M4] 
    at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:734) [catalina.jar:9.0.0.M4] 
    at org.apache.catalina.startup.HostConfig.manageApp(HostConfig.java:1702) [catalina.jar:9.0.0.M4] 
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_31] 
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[?:1.8.0_31] 
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:1.8.0_31] 
    at java.lang.reflect.Method.invoke(Method.java:483) ~[?:1.8.0_31] 
    at org.apache.tomcat.util.modeler.BaseModelMBean.invoke(BaseModelMBean.java:300) [tomcat-coyote.jar:9.0.0.M4] 
05-May-2016 20:40:43.741 SEVERE [RMI TCP Connection(3)-127.0.0.1] org.apache.catalina.core.StandardContext.startInternal One or more listeners failed to start. Full details will be found in the appropriate container log file 
    at com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.invoke(DefaultMBeanServerInterceptor.java:819) [?:1.8.0_31] 
05-May-2016 20:40:43.743 SEVERE [RMI TCP Connection(3)-127.0.0.1] org.apache.catalina.core.StandardContext.startInternal Context [] startup failed due to previous errors 
    at com.sun.jmx.mbeanserver.JmxMBeanServer.invoke(JmxMBeanServer.java:801) [?:1.8.0_31] 
    at org.apache.catalina.mbeans.MBeanFactory.createStandardContext(MBeanFactory.java:482) [catalina.jar:9.0.0.M4] 
    at org.apache.catalina.mbeans.MBeanFactory.createStandardContext(MBeanFactory.java:431) [catalina.jar:9.0.0.M4] 
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_31] 
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[?:1.8.0_31] 
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:1.8.0_31] 
    at java.lang.reflect.Method.invoke(Method.java:483) ~[?:1.8.0_31] 
    at org.apache.tomcat.util.modeler.BaseModelMBean.invoke(BaseModelMBean.java:300) [tomcat-coyote.jar:9.0.0.M4] 
    at com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.invoke(DefaultMBeanServerInterceptor.java:819) [?:1.8.0_31] 
    at com.sun.jmx.mbeanserver.JmxMBeanServer.invoke(JmxMBeanServer.java:801) [?:1.8.0_31] 
    at javax.management.remote.rmi.RMIConnectionImpl.doOperation(RMIConnectionImpl.java:1466) [?:1.8.0_31] 
    at javax.management.remote.rmi.RMIConnectionImpl.access$300(RMIConnectionImpl.java:76) [?:1.8.0_31] 
    at javax.management.remote.rmi.RMIConnectionImpl$PrivilegedOperation.run(RMIConnectionImpl.java:1307) [?:1.8.0_31] 
    at javax.management.remote.rmi.RMIConnectionImpl.doPrivilegedOperation(RMIConnectionImpl.java:1399) [?:1.8.0_31] 
    at javax.management.remote.rmi.RMIConnectionImpl.invoke(RMIConnectionImpl.java:828) [?:1.8.0_31] 
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_31] 
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[?:1.8.0_31] 
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:1.8.0_31] 
    at java.lang.reflect.Method.invoke(Method.java:483) ~[?:1.8.0_31] 
    at sun.rmi.server.UnicastServerRef.dispatch(UnicastServerRef.java:323) [?:1.8.0_31] 
    at sun.rmi.transport.Transport$1.run(Transport.java:200) [?:1.8.0_31] 
    at sun.rmi.transport.Transport$1.run(Transport.java:197) [?:1.8.0_31] 
    at java.security.AccessController.doPrivileged(Native Method) ~[?:1.8.0_31] 
    at sun.rmi.transport.Transport.serviceCall(Transport.java:196) [?:1.8.0_31] 
    at sun.rmi.transport.tcp.TCPTransport.handleMessages(TCPTransport.java:568) [?:1.8.0_31] 
    at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run0(TCPTransport.java:826) [?:1.8.0_31] 
    at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.lambda$run$240(TCPTransport.java:683) [?:1.8.0_31] 
    at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler$$Lambda$1/1480363463.run(Unknown Source) [?:1.8.0_31] 
    at java.security.AccessController.doPrivileged(Native Method) ~[?:1.8.0_31] 
    at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(TCPTransport.java:682) [?:1.8.0_31] 
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) [?:1.8.0_31] 
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) [?:1.8.0_31] 
    at java.lang.Thread.run(Thread.java:745) [?:1.8.0_31] 
Caused by: org.springframework.beans.factory.BeanCreationException: Could not autowire field: private shop.tryHW.core.repository.ClientRepository shop.tryHW.core.service.ClientServiceImpl.clientRepository; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type [shop.tryHW.core.repository.ClientRepository] found for dependency: expected at least 1 bean which qualifies as autowire candidate for this dependency. Dependency annotations: {@org.springframework.beans.factory.annotation.Autowired(required=true)} 
    at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:573) ~[spring-beans-4.2.5.RELEASE.jar:4.2.5.RELEASE] 
    at org.springframework.beans.factory.annotation.InjectionMetadata.inject(InjectionMetadata.java:88) ~[spring-beans-4.2.5.RELEASE.jar:4.2.5.RELEASE] 
    at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessPropertyValues(AutowiredAnnotationBeanPostProcessor.java:331) ~[spring-beans-4.2.5.RELEASE.jar:4.2.5.RELEASE] 
    ... 59 more 
Caused by: org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type [shop.tryHW.core.repository.ClientRepository] found for dependency: expected at least 1 bean which qualifies as autowire candidate for this dependency. Dependency annotations: {@org.springframework.beans.factory.annotation.Autowired(required=true)} 
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.raiseNoSuchBeanDefinitionException(DefaultListableBeanFactory.java:1373) ~[spring-beans-4.2.5.RELEASE.jar:4.2.5.RELEASE] 
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:1119) ~[spring-beans-4.2.5.RELEASE.jar:4.2.5.RELEASE] 
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:1014) ~[spring-beans-4.2.5.RELEASE.jar:4.2.5.RELEASE] 
    at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:545) ~[spring-beans-4.2.5.RELEASE.jar:4.2.5.RELEASE] 
    at org.springframework.beans.factory.annotation.InjectionMetadata.inject(InjectionMetadata.java:88) ~[spring-beans-4.2.5.RELEASE.jar:4.2.5.RELEASE] 
    at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessPropertyValues(AutowiredAnnotationBeanPostProcessor.java:331) ~[spring-beans-4.2.5.RELEASE.jar:4.2.5.RELEASE] 
    ... 59 more 
[2016-05-05 08:40:43,811] Artifact tryHW-web:war exploded: Error during artifact deployment. See server log for details. 
05-May-2016 20:40:45.124 INFO [localhost-startStop-1] org.apache.catalina.startup.HostConfig.deployDirectory Deploying web application directory D:\Prog\apache-tomcat-9.0.0.M4\webapps\manager 
05-May-2016 20:40:45.448 INFO [localhost-startStop-1] org.apache.catalina.startup.HostConfig.deployDirectory Deployment of web application directory D:\Prog\apache-tomcat-9.0.0.M4\webapps\manager has finished in 323 ms 

<listener> 
     <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class> 
    </listener> 

    <servlet> 
     **<servlet-name>rest</servlet-name> <-------here I get Servlet should have mapping** 
     <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class> 
     <load-on-startup>1</load-on-startup> 
    </servlet> 

    <servlet-mapping> 
     **<servlet-name>rest</servlet-name> <---Here I get cannot find servlet** 
     <url-pattern>/api/*</url-pattern> 
    </servlet-mapping> 

を私が持っている唯一のマッピングが

@RestController 
public class ClientController { 

    @Autowired 
    private ClientService clientService; 

    @RequestMapping(value="/clients", method = RequestMethod.GET, produces = "application/vnd.api+json") 
    public ClientsDto getClients() { 
     List<Client> clientList = clientService.findAll(); 
     return new ClientsDto(clientList); 
    } 
} 

私はTomcatを実行しようとすると、私が手に完全なエラーがありますここで

ClientControllerためのコードです:

@RestController 
public class ClientController { 

    @Autowired 
    private ClientService clientService; 

    @RequestMapping(value="/clients", method = RequestMethod.GET, produces = "application/vnd.api+json") 
    public ClientsDto getClients() { 
     List<Client> clientList = clientService.findAll(); 
     return new ClientsDto(clientList); 
    } 

} 

私は何が私に尋ねているのか、何が問題なのか全く分かりません。 何が間違っていますか?私はそれが私から何を求めているのか理解していない。私はコンテクストxmlやそのようなものは持っていません。私はweb.xmlしか持っていません

これは、クラスのインスタンス化に関連する方法は何ですか?なぜ@Autowiredは動作しませんか?

+0

また、エラーを投稿する必要があります – Eliethesaiyan

+0

これを追加しました。必要に応じて投稿することができます – Mocktheduck

答えて

0

ClientRepositoryは、春のアプリケーションコンテキストにスキャンされていません。その上に@Repositoryアノテーションがあるか、他のビーンアノテーションがあることを確認し、春のフレームワークによって自動的にスキャンすることができます。走査経路上のその基本パッケージなど。

+0

これは問題の1つです。私は適切な注釈を追加するのを忘れましたが、修正しませんでした。それはSchemaLocationにつながります:schemaLocation value = 'http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-3.1.xsd http://www.springframework .org/schema/beans http://www.springframework.org/schema/beans/spring-beans-4.0.xsd http://www.springframework.org/schema/mvc 'には偶数のURIが必要です。そして、同じBeanエラーを再びスローします。 – Mocktheduck

+0

完全なXMLコンテキスト設定を投稿してください。 –

+0

完全なエラーメッセージといっしょにするか、プロジェクトをgithubに公開するだけで良い答えになると便利です。 –

関連する問題