Java WebService Spring不支持';t初始化服务和使用者的bean

Java WebService Spring不支持';t初始化服务和使用者的bean,java,spring,maven,web-services,soap,Java,Spring,Maven,Web Services,Soap,我正在用SOAP创建webService Spring,但遇到了一个问题。一开始,我用SpringMVC做了一个webapp,其中包含服务和消费者(SpringData和SpringJDBC),其中公开了接口及其工作。所以我想问题不是来自这些模块 但是现在,我想在我的Web服务中重用我的服务和消费者,但它不起作用。我用maven做了一个新的原型,添加了许多依赖项,如果我不使用我的服务或消费者(仅Web服务),我可以使用SOAPUI并返回一个字符串 然而,一旦我尝试连接我的服务和我的消费者,我的T

我正在用SOAP创建webService Spring,但遇到了一个问题。一开始,我用SpringMVC做了一个webapp,其中包含服务和消费者(SpringData和SpringJDBC),其中公开了接口及其工作。所以我想问题不是来自这些模块

但是现在,我想在我的Web服务中重用我的服务和消费者,但它不起作用。我用maven做了一个新的原型,添加了许多依赖项,如果我不使用我的服务或消费者(仅Web服务),我可以使用SOAPUI并返回一个字符串

然而,一旦我尝试连接我的服务和我的消费者,我的TomCat日志告诉我,我的注入依赖性不令人满意。。。我不明白为什么

PS:我已经从我的webapp MVC复制粘贴到我的webService,我是java的初学者

TomCat本地主机日志:

2019年1月10日04:28:11.625 INFOS[RMI TCP连接(3)-127.0.0.1]org.apache.catalina.core.ApplicationContext.log在类路径上未检测到Spring WebApplicationInitializer类型 2019年1月10日04:28:11.645 INFOS[RMI TCP连接(3)-127.0.0.1]org.apache.catalina.core.ApplicationContext.log初始化Spring根WebApplicationContext 2019年1月10日04:28:16.754 GRAVE[RMI TCP连接(3)-127.0.0.1]org.apache.catalina.core.StandardContext.listenerStart例外lors de l'envoi de lévènement contexte initialisé(上下文初始化)l'instance de classe d'coute(侦听器)[org.springframework web.context.ContextLoaderListener] org.springframework.beans.factory.UnsatifiedDependencyException:创建名为“FrokingServiceImpl”的bean时出错:通过字段“FrokingRepository”表示未满足的依赖关系;嵌套异常为org.springframework.beans.factory.NoSuchBean定义异常:没有“p3.repository.FroyingRepository”类型的合格bean可用:至少需要1个符合autowire候选条件的bean。依赖项注释:{@org.springframework.beans.factory.annotation.Autowired(required=true)} 位于org.springframework.beans.factory.annotation.AutoWiredNotationBeanPostProcessor$AutoWiredFeldElement.inject(AutoWiredNotationBeanPostProcessor.java:596) 位于org.springframework.beans.factory.annotation.InjectionMetadata.inject(InjectionMetadata.java:90)

我的pom.xml

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <parent>
        <artifactId>library</artifactId>
        <groupId>p3</groupId>
        <version>1.0-SNAPSHOT</version>
    </parent>
    <modelVersion>4.0.0</modelVersion>


    <artifactId>webService</artifactId>
    <version>1.0-SNAPSHOT</version>
    <packaging>war</packaging>

    <name>webService</name>
    <!-- FIXME change it to the project's website -->
    <!--<url>http://www.example.com</url>-->

    <properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <maven.compiler.source>1.7</maven.compiler.source>
        <maven.compiler.target>1.7</maven.compiler.target>
        <!-- tools de génération WS pour OS Linux et Max -->
        <tool.wsgen>${java.home}/../bin/wsgen</tool.wsgen>
    </properties>

    <dependencies>

        <!-- ===== Modules ===== -->
        <dependency>
            <groupId>p3</groupId>
            <artifactId>service</artifactId>
        </dependency>
        <dependency>
            <groupId>p3</groupId>
            <artifactId>model</artifactId>
        </dependency>
        <!-- https://mvnrepository.com/artifact/com.sun.xml.ws/jaxws-ri -->
        <dependency>
            <groupId>com.sun.xml.ws</groupId>
            <artifactId>jaxws-ri</artifactId>
            <type>pom</type>
        </dependency>
        <!-- https://mvnrepository.com/artifact/org.glassfish.ha/ha-api -->
        <dependency>
            <groupId>org.glassfish.ha</groupId>
            <artifactId>ha-api</artifactId>
        </dependency>
        <!-- https://mvnrepository.com/artifact/com.sun.xml.bind/jaxb-impl -->
        <dependency>
            <groupId>com.sun.xml.bind</groupId>
            <artifactId>jaxb-impl</artifactId>
        </dependency>


        <dependency>
            <groupId>com.sun.xml.ws</groupId>
            <artifactId>jaxws-rt</artifactId>
        </dependency>
        <!-- https://mvnrepository.com/artifact/org.springframework.ws/spring-ws -->
        <dependency>
            <groupId>org.springframework.ws</groupId>
            <artifactId>spring-ws</artifactId>
            <version>3.0.4.RELEASE</version>
            <type>pom</type>
        </dependency>
        <dependency>
            <groupId>org.apache.commons</groupId>
            <artifactId>commons-text</artifactId>
            <version>1.1</version>
            <exclusions>
                <!-- La dépendance vers commons-lang3 est exclue -->
                <exclusion>
                    <groupId>org.apache.commons</groupId>
                    <artifactId>commons-lang3</artifactId>
                </exclusion>
            </exclusions>
        </dependency>
        <!-- https://mvnrepository.com/artifact/commons-lang/commons-lang -->
        <dependency>
            <groupId>commons-lang</groupId>
            <artifactId>commons-lang</artifactId>
            <version>2.6</version>
        </dependency>

        <dependency>
            <groupId>org.hibernate.common</groupId>
            <artifactId>hibernate-commons-annotations</artifactId>
            <version>5.0.1.Final</version>
        </dependency>
        <dependency>
            <groupId>org.hibernate</groupId>
            <artifactId>hibernate-c3p0</artifactId>
            <version>${hibernate.version}</version>
        </dependency>
        <dependency>
            <groupId>javassist</groupId>
            <artifactId>javassist</artifactId>
            <version>3.12.1.GA</version>
        </dependency>
        <!-- deriver MySql -->
        <dependency>
            <groupId>mysql</groupId>
            <artifactId>mysql-connector-java</artifactId>
        </dependency>
        <!-- https://mvnrepository.com/artifact/javax.servlet/javax.servlet-api -->
        <dependency>
            <groupId>javax.servlet</groupId>
            <artifactId>javax.servlet-api</artifactId>
            <version>4.0.1</version>
            <scope>provided</scope>
        </dependency>
        <!-- https://mvnrepository.com/artifact/jstl/jstl -->
        <dependency>
            <groupId>jstl</groupId>
            <artifactId>jstl</artifactId>
            <version>1.2</version>
        </dependency>
        <!-- https://mvnrepository.com/artifact/javax.servlet/jsp-api -->
        <dependency>
            <groupId>javax.servlet</groupId>
            <artifactId>jsp-api</artifactId>
            <version>2.0</version>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>javax.xml.ws</groupId>
            <artifactId>jaxws-api</artifactId>
            <version>2.2.11</version>
        </dependency>
        <dependency>
            <groupId>javax.servlet</groupId>
            <artifactId>servlet-api</artifactId>
            <version>2.5</version>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>javax.validation</groupId>
            <artifactId>validation-api</artifactId>
            <scope>compile</scope>
        </dependency>
        <dependency>
            <groupId>org.apache.bval</groupId>
            <artifactId>bval-jsr</artifactId>
        </dependency>

        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-web</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-context</artifactId>
            <version>${spring.version}</version>
            <exclusions>
                <!-- Exclude Commons Logging in favor of SLF4j -->
                <!--<exclusion>-->
                <!--<groupId>commons-logging</groupId>-->
                <!--<artifactId>commons-logging</artifactId>-->
                <!--</exclusion>-->
            </exclusions>
        </dependency>
        <!-- https://mvnrepository.com/artifact/org.springframework/spring-webmvc -->
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-webmvc</artifactId>
            <version>5.1.3.RELEASE</version>
        </dependency>
        <dependency>
            <groupId>javax.xml.bind</groupId>
            <artifactId>jaxb-api</artifactId>
            <version>2.4.0-b180830.0359</version>
        </dependency>
        <dependency>
            <groupId>org.glassfish.jaxb</groupId>
            <artifactId>jaxb-runtime</artifactId>
            <version>2.3.0</version>
        </dependency>
        <dependency>
            <groupId>javax.activation</groupId>
            <artifactId>activation</artifactId>
            <version>1.1.1</version>
        </dependency>
        <!-- https://mvnrepository.com/artifact/org.apache.axis2/axis2-kernel -->
        <dependency>
            <groupId>org.apache.axis2</groupId>
            <artifactId>axis2-kernel</artifactId>
        </dependency>


        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <version>4.11</version>
            <scope>test</scope>
        </dependency>
    </dependencies>

    <build>
        <pluginManagement><!-- lock down plugins versions to avoid using Maven defaults (may be moved to parent pom) -->
            <plugins>

                <plugin>
                    <artifactId>maven-war-plugin</artifactId>
                    <configuration>
                        <failOnMissingWebXml>false</failOnMissingWebXml>
                    </configuration>
                </plugin>

                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-compiler-plugin</artifactId>
                    <version>3.7.0</version>
                    <configuration>
                        <source>1.8</source>
                        <target>1.8</target>
                    </configuration>
                </plugin>
                <plugin>
                    <groupId>org.apache.cxf</groupId>
                    <artifactId>cxf-codegen-plugin</artifactId>
                    <version>${cxf.version}</version>
                    <executions>
                        <execution>
                            <id>generate-sources</id>
                            <phase>generate-sources</phase>
                            <configuration>
                                <sourceRoot>${project.build.directory}/generated/cxf</sourceRoot>
                                <wsdlOptions>
                                    <wsdlOption>
                                        <wsdl>${basedir}/src/main/resources/myService.wsdl</wsdl>
                                    </wsdlOption>
                                </wsdlOptions>
                            </configuration>
                            <goals>
                                <goal>wsdl2java</goal>
                            </goals>
                        </execution>
                    </executions>
                </plugin>
            </plugins>
        </pluginManagement>
    </build>
</project>
Web服务实现

package p3.webServiceImpl;

import org.springframework.beans.factory.annotation.Autowired;
import p3.model.borrowing.Borrowing;
import p3.repository.BorrowingRepository;
import p3.service.BorrowingService;
import p3.webService.batchWebService;

import javax.inject.Inject;
import javax.jws.WebMethod;
import javax.jws.WebService;
import javax.jws.soap.SOAPBinding;
import java.util.Calendar;
import java.util.Date;
import java.util.List;

@WebService(endpointInterface = "p3.webService.batchWebService")
@SOAPBinding(style = SOAPBinding.Style.RPC)
public class batchWebServiceImplWS implements batchWebService {

@Autowired
private BorrowingService borrowingService;

@Override
@WebMethod
public String batchMethod(String test) {
        System.out.println(borrowingService.sendMailBorrowingExceeded());
        return "Hello toto ! " + test + " borrow : " ;
    }
}
具有端点的发布服务器

package p3.publisher;

import p3.webServiceImpl.batchWebServiceImplWS;

import javax.xml.ws.Endpoint;

public class batchWebServicePublisher {
    public static final String URL = "http://localhost:8080/webService_war/";

    public static void main(String[] args) {
        batchWebServiceImplWS impl = new batchWebServiceImplWS();

        Endpoint endpoint = Endpoint.publish(URL, impl);

        boolean status = endpoint.isPublished();
        System.out.println("Web serviceBoot disponible ? : " + status);
    }
}

在application-context.xml文件中,添加此属性

<jpa:repositories base-package="p3.repository"/>.

由于缺少此配置,Spring容器无法找到bean。

在application-context.xml文件中,添加此属性。由于缺少此配置,Spring容器无法找到bean。我得到了您的建议,我的IDE告诉我:无法解析包借用存储库少。。。(Ctrl+F1)检查信息:SpringXML模型验证|我认为它没有阅读这个基本包。。。在我的tomcat日志中,我总是有与“p3.repository”相同的问题。我认为您的包名借用存储库在p3.repository中。那就试试吧。你说得对,我的雄猫现在可以跑了!非常感谢!但当我尝试使用SOAPUI时,我总是有一个NPE(我将进一步研究它),因为它解决了您的问题,所以“答案”不应该出现在评论部分。所以让我写下这个评论作为回答。
package p3.webService;

import p3.model.borrowing.Borrowing;

import javax.jws.WebMethod;
import javax.jws.WebParam;
import javax.jws.WebService;
import javax.jws.soap.SOAPBinding;
import java.util.List;

@WebService
@SOAPBinding(style = SOAPBinding.Style.RPC)
public interface batchWebService extends java.rmi.Remote {
@WebMethod
String batchMethod (@WebParam(name="nom") String test);
}
package p3.webServiceImpl;

import org.springframework.beans.factory.annotation.Autowired;
import p3.model.borrowing.Borrowing;
import p3.repository.BorrowingRepository;
import p3.service.BorrowingService;
import p3.webService.batchWebService;

import javax.inject.Inject;
import javax.jws.WebMethod;
import javax.jws.WebService;
import javax.jws.soap.SOAPBinding;
import java.util.Calendar;
import java.util.Date;
import java.util.List;

@WebService(endpointInterface = "p3.webService.batchWebService")
@SOAPBinding(style = SOAPBinding.Style.RPC)
public class batchWebServiceImplWS implements batchWebService {

@Autowired
private BorrowingService borrowingService;

@Override
@WebMethod
public String batchMethod(String test) {
        System.out.println(borrowingService.sendMailBorrowingExceeded());
        return "Hello toto ! " + test + " borrow : " ;
    }
}
package p3.publisher;

import p3.webServiceImpl.batchWebServiceImplWS;

import javax.xml.ws.Endpoint;

public class batchWebServicePublisher {
    public static final String URL = "http://localhost:8080/webService_war/";

    public static void main(String[] args) {
        batchWebServiceImplWS impl = new batchWebServiceImplWS();

        Endpoint endpoint = Endpoint.publish(URL, impl);

        boolean status = endpoint.isPublished();
        System.out.println("Web serviceBoot disponible ? : " + status);
    }
}
<jpa:repositories base-package="p3.repository"/>.