运行 .JAR 文件时创建 bean 时出错
Error creating bean when running .JAR file
我有一个 Java 应用程序,带有 Spring 引导,使用 MySQL 数据库和 Spring 安全性构建。
该应用程序的目的是连接到 SOAP API 并使用 Thymleaf 的前端与数据进行交互。
当 运行 使用 IntelliJ IDEA 在本地主机上使用所有 SOAP 连接时,该项目工作正常。
运行 mvn clean package
时,fat jar 构建成功。
我想将 jar 文件部署到托管服务器。
感谢任何帮助。
但是当 运行 它使用 java -jar <your_app_name>-<your_app_version>.jar
它崩溃并给出以下错误:
错误
2021-10-02 12:47:58.149 WARN 32908 --- [ main] ConfigServletWebServerApplicationContext : Exception encountered during context initialization - cancelling refresh attempt: o
rg.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'authController' defined in URL [jar:file:/C:/Users/amerm/Downloads/Compressed/project_name/target/project_name-0.0.1-SNAPSHOT.jar!/BOOT-INF/classes!/com/project_name/PersonDetailsClient/Controller/AuthController.class]: Unsatisfied dependency expressed through constr
uctor parameter 2; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'personDetailsServiceImpl' defined in URL [jar:fi
le:/C:/Users/amerm/Downloads/Compressed/project_name/target/project_name-0.0.1-SNAPSHOT.jar!/BOOT-INF/classes!/com/project_name/PersonDetailsClient/Service/ServiceImpl/PersonDetai
lsServiceImpl.class]: Unsatisfied dependency expressed through constructor parameter 0; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean
with name 'personDetailsClient' defined in class path resource [com/project_name/PersonDetailsClient/Config/PersonDetailsClientConfiguration.class]: Bean instantiation via fact
ory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [com.project.name.PersonDetailsClient.PersonDetailsClient]: Fa
ctory method 'personDetailsClient' threw exception; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.ws.soap.saaj.Sa
ajSoapMessageFactory]: Unresolvable class definition; nested exception is java.lang.NoClassDefFoundError: javax/xml/soap/SOAPException
AuthController
@Controller
@RequestMapping(value = "/")
public class AuthController {
@Autowired
public AuthController(UserService userService, RoleDao roleDao, IPersonDetailsService personDetailsService) {
this.personDetailsService = personDetailsService;
this.userService = userService;
this.roleDao = roleDao;
}
private IPersonDetailsService personDetailsService;
private UserService userService;
private RoleDao roleDao;
@RequestMapping
public String home(){
return "redirect:/index";
}
@RequestMapping("index")
public String index(){
return "index";
}
@RequestMapping(value = "signup", method = RequestMethod.GET)
public String signup(Model model) {
PersonDetails personDetails = new PersonDetails();
model.addAttribute("user", personDetails);
return "signup";
}
@RequestMapping(value = "signup", method = RequestMethod.POST)
public String signupPost(@ModelAttribute("user") PersonDetails newPersonDetails, Model model) throws DatatypeConfigurationException {
if (userService.checkUserExists(newPersonDetails.getUsername(), newPersonDetails.getEmailAddress())) {
if (userService.checkEmailExists(newPersonDetails.getEmailAddress())) {
model.addAttribute("emailExists", true);
}
if (userService.checkUsernameExists(newPersonDetails.getUsername())) {
model.addAttribute("usernameExists", true);
}
return "signup";
} else {
Set<UserRole> userRoles = new HashSet<>();
userRoles.add(new UserRole(newPersonDetails, roleDao.findByName("ROLE_USER")));
String personId = personDetailsService.findPersonByVariant1(newPersonDetails.getLastName(), newPersonDetails.getInitials(), newPersonDetails.getDateOfBirth()).getPersonDetails().getPersonId();
userService.createUser(newPersonDetails, userRoles);
PersonDetails user = userService.findByUsername(newPersonDetails.getUsername());
user.setPersonId(personId);
userService.saveUser(user);
if (personId == null){
String personIdCreated = personDetailsService.createPersonByVariant1(newPersonDetails.getLastName(), newPersonDetails.getInitials(), newPersonDetails.getDateOfBirth()).getPersonDetails().getPersonId();
userService.createUser(newPersonDetails, userRoles);
PersonDetails person = userService.findByUsername(newPersonDetails.getUsername());
person.setPersonId(personIdCreated);
userService.saveUser(newPersonDetails);
}
return "redirect:/";
}
}
}
PersonDetailsServiceImpl
@Service
public class PersonDetailsServiceImpl implements IPersonDetailsService {
final String PersonDetailsEndPoint = "ENDPOINT_URL";
final String userId = "NUM";
final String organisationToken = "NUM";
PersonDetailsClient personDetailsClient;
@Autowired
public PersonDetailsServiceImpl(PersonDetailsClient personDetailsClient) {
this.personDetailsClient = personDetailsClient;
}
@Override
public GetPersonDetailsResponse findPersonByVariant1(String lastName, String initials, Date dateOfBirth) throws DatatypeConfigurationException {
ObjectFactory objectFactory = new ObjectFactory();
GetPersonDetailsRequest.PersonDetails person = objectFactory.createGetPersonDetailsRequestPersonDetails();
person.setLastName(lastName);
person.setInitials(initials);
GregorianCalendar bgc = new GregorianCalendar();
bgc.setTime(dateOfBirth);
XMLGregorianCalendar bDate = DatatypeFactory.newInstance().newXMLGregorianCalendar(bgc);
person.setDateOfBirth(bDate);
GetPersonDetailsRequest getPersonDetailsRequest = objectFactory.createGetPersonDetailsRequest();
getPersonDetailsRequest.setPersonDetails(person);
GetPersonDetailsResponse getPersonDetailsResponse = personDetailsClient.getPersonDetailsResponse(PersonDetailsEndPoint, getPersonDetailsRequest, new TokenHeaderRequestCallback(userId, organisationToken));
return getPersonDetailsResponse;
}
@Override
public CreatePersonDetailsResponse createPersonByVariant1(String lastName, String initials, Date dateOfBirth) throws DatatypeConfigurationException {
try {
ObjectFactory objectFactory = new ObjectFactory();
CreatePersonDetailsRequest.PersonDetails person = objectFactory.createCreatePersonDetailsRequestPersonDetails();
person.setLastName(lastName);
person.setInitials(initials);
GregorianCalendar bgc = new GregorianCalendar();
bgc.setTime(dateOfBirth);
XMLGregorianCalendar bDate = DatatypeFactory.newInstance().newXMLGregorianCalendar(bgc);
person.setDateOfBirth(bDate);
CreatePersonDetailsRequest createPersonDetailsRequest = objectFactory.createCreatePersonDetailsRequest();
createPersonDetailsRequest.setPersonDetails(person);
CreatePersonDetailsResponse createPersonDetailsResponse = personDetailsClient.createPersonDetailsResponse(PersonDetailsEndPoint, createPersonDetailsRequest, new TokenHeaderRequestCallback(userId, organisationToken));
return createPersonDetailsResponse;
} catch (SoapFaultClientException soapFaultClientException) {
return null;
}
}
@Override
public CheckChangesPersonDetailsResponse checkPersonChanges(String personId, String title, String lastName, String initials, String firstName, String infix, Date dateOfBirth, String streetName, String houseNumber, String houseNumberAddition, String postalCode, String residence, String country, String countryOfBirth, String lastNameOfBirth, String infixOfBirth, String nationality, GenderType gender, String insurancePolicy, String policyNumber, String socialSecurityNumber, Date dateOfDeath, String telephone, String emailAddress) throws DatatypeConfigurationException {
...
}
@Override
public UpdatePersonDetailsResponse updatePersonDetails(String personId, String title, String lastName, String initials, String firstName, String infix, Date dateOfBirth, String streetName, String houseNumber, String houseNumberAddition, String postalCode, String residence, String country, String countryOfBirth, String lastNameOfBirth, String infixOfBirth, String nationality, GenderType gender, String insurancePolicy, String policyNumber, String socialSecurityNumber, Date dateOfDeath, String telephone, String emailAddress) throws DatatypeConfigurationException {
...
}
}
PersonDetailsClientConfiguration
@Configuration
public class PersonDetailsClientConfiguration {
@Bean
public Jaxb2Marshaller marshaller() throws Exception {
Jaxb2Marshaller marshaller = new Jaxb2Marshaller();
marshaller.setContextPath("com.<project_name>.stub");
marshaller.afterPropertiesSet();
return marshaller;
}
@Bean
public WebServiceTemplate webServiceTemplate(Jaxb2Marshaller marshaller) {
WebServiceTemplate webServiceTemplate = new WebServiceTemplate();
webServiceTemplate.setDefaultUri("ENDPOINT_URL");
webServiceTemplate.setMarshaller(marshaller);
webServiceTemplate.setUnmarshaller(marshaller);
return webServiceTemplate;
}
@Bean
public PersonDetailsClient personDetailsClient(Jaxb2Marshaller marshaller) {
PersonDetailsClient personDetailsClient = new PersonDetailsClient();
personDetailsClient.setDefaultUri("ENDPOINT_URL");
personDetailsClient.setMarshaller(marshaller);
personDetailsClient.setUnmarshaller(marshaller);
return personDetailsClient;
}
}
PersonDetailsClient
public class PersonDetailsClient extends WebServiceGatewaySupport {
public GetPersonDetailsResponse getPersonDetailsResponse(String personDetailsEndPoint, GetPersonDetailsRequest getPersonDetailsRequest, TokenHeaderRequestCallback tokenHeaderRequestCallback) {
GetPersonDetailsResponse getPersonDetailsResponse = (GetPersonDetailsResponse) getWebServiceTemplate().marshalSendAndReceive(personDetailsEndPoint, getPersonDetailsRequest, tokenHeaderRequestCallback);
return getPersonDetailsResponse;
}
public CreatePersonDetailsResponse createPersonDetailsResponse (String personDetailsEndPoint, CreatePersonDetailsRequest createPersonDetailsRequest, TokenHeaderRequestCallback tokenHeaderRequestCallback) {
CreatePersonDetailsResponse createPersonDetailsResponse = (CreatePersonDetailsResponse) getWebServiceTemplate().marshalSendAndReceive(personDetailsEndPoint, createPersonDetailsRequest, tokenHeaderRequestCallback);
return createPersonDetailsResponse;
}
public CheckChangesPersonDetailsResponse checkChangesPersonDetailsResponse (String personDetailsEndPoint, CheckChangesPersonDetailsRequest checkChangesPersonDetailsRequest, TokenHeaderRequestCallback tokenHeaderRequestCallback) {
CheckChangesPersonDetailsResponse checkChangesPersonDetailsResponse = (CheckChangesPersonDetailsResponse) getWebServiceTemplate().marshalSendAndReceive(personDetailsEndPoint, checkChangesPersonDetailsRequest, tokenHeaderRequestCallback);
return checkChangesPersonDetailsResponse;
}
public UpdatePersonDetailsResponse updatePersonDetailsResponse (String personDetailsEndPoint, UpdatePersonDetailsRequest updatePersonDetailsRequest, TokenHeaderRequestCallback tokenHeaderRequestCallback) {
UpdatePersonDetailsResponse updatePersonDetailsResponse = (UpdatePersonDetailsResponse) getWebServiceTemplate().marshalSendAndReceive(personDetailsEndPoint, updatePersonDetailsRequest, tokenHeaderRequestCallback);
return updatePersonDetailsResponse;
}
}
pom.xml
<?xml version="1.0" encoding="UTF-8"?>
<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 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.5.4</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<groupId>com.<group_name></groupId>
<artifactId><artifactId></artifactId>
<version>0.0.1-SNAPSHOT</version>
<name><Project_name></name>
<properties>
<java.version>8</java.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-devtools</artifactId>
<scope>runtime</scope>
<optional>true</optional>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-security</artifactId>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-thymeleaf</artifactId>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-oxm</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.ws</groupId>
<artifactId>spring-ws-core</artifactId>
</dependency>
</dependencies>
<distributionManagement>
<snapshotRepository>
<uniqueVersion>false</uniqueVersion>
<id>snapshot</id>
<name>Carewebport Snapshots</name>
<url>https://repo.maven.apache.org/maven2</url>
<layout>default</layout>
</snapshotRepository>
</distributionManagement>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
<plugin>
<groupId>org.jvnet.jaxb2.maven2</groupId>
<artifactId>maven-jaxb2-plugin</artifactId>
<version>0.14.0</version>
<configuration>
<schemaLanguage>WSDL</schemaLanguage>
<generatePackage>com.<project_name>.stub</generatePackage>
<schemas>
<schema>
<url>URL.WSDL</url>
</schema>
</schemas>
</configuration>
<executions>
<execution>
<goals>
<goal>generate</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
1.In sts/eclipse 键入 ctrl+t 并键入 class 名称。如果找到然后记下它来自的 jar 名称让我们说 x。如果在 class 路径上找不到,那么您必须在 class 存在的地方添加依赖项
2 使用任何 zip 提取器打开在目标文件夹下构建的 jar,然后在 WEB-INF/lib 文件夹中检查 jar x 是否在该 x jar 下找到 javax/xml/soap/SOAPException。
这可能是由于您在运行时使用的 Java 版本所致。您必须将 javax ws 包添加为依赖项,因为它不再与较新的 Java 版本捆绑在一起。有关详细信息,请参阅
我有一个 Java 应用程序,带有 Spring 引导,使用 MySQL 数据库和 Spring 安全性构建。 该应用程序的目的是连接到 SOAP API 并使用 Thymleaf 的前端与数据进行交互。
当 运行 使用 IntelliJ IDEA 在本地主机上使用所有 SOAP 连接时,该项目工作正常。
运行 mvn clean package
时,fat jar 构建成功。
我想将 jar 文件部署到托管服务器。
感谢任何帮助。
但是当 运行 它使用 java -jar <your_app_name>-<your_app_version>.jar
它崩溃并给出以下错误:
错误
2021-10-02 12:47:58.149 WARN 32908 --- [ main] ConfigServletWebServerApplicationContext : Exception encountered during context initialization - cancelling refresh attempt: o
rg.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'authController' defined in URL [jar:file:/C:/Users/amerm/Downloads/Compressed/project_name/target/project_name-0.0.1-SNAPSHOT.jar!/BOOT-INF/classes!/com/project_name/PersonDetailsClient/Controller/AuthController.class]: Unsatisfied dependency expressed through constr
uctor parameter 2; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'personDetailsServiceImpl' defined in URL [jar:fi
le:/C:/Users/amerm/Downloads/Compressed/project_name/target/project_name-0.0.1-SNAPSHOT.jar!/BOOT-INF/classes!/com/project_name/PersonDetailsClient/Service/ServiceImpl/PersonDetai
lsServiceImpl.class]: Unsatisfied dependency expressed through constructor parameter 0; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean
with name 'personDetailsClient' defined in class path resource [com/project_name/PersonDetailsClient/Config/PersonDetailsClientConfiguration.class]: Bean instantiation via fact
ory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [com.project.name.PersonDetailsClient.PersonDetailsClient]: Fa
ctory method 'personDetailsClient' threw exception; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.ws.soap.saaj.Sa
ajSoapMessageFactory]: Unresolvable class definition; nested exception is java.lang.NoClassDefFoundError: javax/xml/soap/SOAPException
AuthController
@Controller
@RequestMapping(value = "/")
public class AuthController {
@Autowired
public AuthController(UserService userService, RoleDao roleDao, IPersonDetailsService personDetailsService) {
this.personDetailsService = personDetailsService;
this.userService = userService;
this.roleDao = roleDao;
}
private IPersonDetailsService personDetailsService;
private UserService userService;
private RoleDao roleDao;
@RequestMapping
public String home(){
return "redirect:/index";
}
@RequestMapping("index")
public String index(){
return "index";
}
@RequestMapping(value = "signup", method = RequestMethod.GET)
public String signup(Model model) {
PersonDetails personDetails = new PersonDetails();
model.addAttribute("user", personDetails);
return "signup";
}
@RequestMapping(value = "signup", method = RequestMethod.POST)
public String signupPost(@ModelAttribute("user") PersonDetails newPersonDetails, Model model) throws DatatypeConfigurationException {
if (userService.checkUserExists(newPersonDetails.getUsername(), newPersonDetails.getEmailAddress())) {
if (userService.checkEmailExists(newPersonDetails.getEmailAddress())) {
model.addAttribute("emailExists", true);
}
if (userService.checkUsernameExists(newPersonDetails.getUsername())) {
model.addAttribute("usernameExists", true);
}
return "signup";
} else {
Set<UserRole> userRoles = new HashSet<>();
userRoles.add(new UserRole(newPersonDetails, roleDao.findByName("ROLE_USER")));
String personId = personDetailsService.findPersonByVariant1(newPersonDetails.getLastName(), newPersonDetails.getInitials(), newPersonDetails.getDateOfBirth()).getPersonDetails().getPersonId();
userService.createUser(newPersonDetails, userRoles);
PersonDetails user = userService.findByUsername(newPersonDetails.getUsername());
user.setPersonId(personId);
userService.saveUser(user);
if (personId == null){
String personIdCreated = personDetailsService.createPersonByVariant1(newPersonDetails.getLastName(), newPersonDetails.getInitials(), newPersonDetails.getDateOfBirth()).getPersonDetails().getPersonId();
userService.createUser(newPersonDetails, userRoles);
PersonDetails person = userService.findByUsername(newPersonDetails.getUsername());
person.setPersonId(personIdCreated);
userService.saveUser(newPersonDetails);
}
return "redirect:/";
}
}
}
PersonDetailsServiceImpl
@Service
public class PersonDetailsServiceImpl implements IPersonDetailsService {
final String PersonDetailsEndPoint = "ENDPOINT_URL";
final String userId = "NUM";
final String organisationToken = "NUM";
PersonDetailsClient personDetailsClient;
@Autowired
public PersonDetailsServiceImpl(PersonDetailsClient personDetailsClient) {
this.personDetailsClient = personDetailsClient;
}
@Override
public GetPersonDetailsResponse findPersonByVariant1(String lastName, String initials, Date dateOfBirth) throws DatatypeConfigurationException {
ObjectFactory objectFactory = new ObjectFactory();
GetPersonDetailsRequest.PersonDetails person = objectFactory.createGetPersonDetailsRequestPersonDetails();
person.setLastName(lastName);
person.setInitials(initials);
GregorianCalendar bgc = new GregorianCalendar();
bgc.setTime(dateOfBirth);
XMLGregorianCalendar bDate = DatatypeFactory.newInstance().newXMLGregorianCalendar(bgc);
person.setDateOfBirth(bDate);
GetPersonDetailsRequest getPersonDetailsRequest = objectFactory.createGetPersonDetailsRequest();
getPersonDetailsRequest.setPersonDetails(person);
GetPersonDetailsResponse getPersonDetailsResponse = personDetailsClient.getPersonDetailsResponse(PersonDetailsEndPoint, getPersonDetailsRequest, new TokenHeaderRequestCallback(userId, organisationToken));
return getPersonDetailsResponse;
}
@Override
public CreatePersonDetailsResponse createPersonByVariant1(String lastName, String initials, Date dateOfBirth) throws DatatypeConfigurationException {
try {
ObjectFactory objectFactory = new ObjectFactory();
CreatePersonDetailsRequest.PersonDetails person = objectFactory.createCreatePersonDetailsRequestPersonDetails();
person.setLastName(lastName);
person.setInitials(initials);
GregorianCalendar bgc = new GregorianCalendar();
bgc.setTime(dateOfBirth);
XMLGregorianCalendar bDate = DatatypeFactory.newInstance().newXMLGregorianCalendar(bgc);
person.setDateOfBirth(bDate);
CreatePersonDetailsRequest createPersonDetailsRequest = objectFactory.createCreatePersonDetailsRequest();
createPersonDetailsRequest.setPersonDetails(person);
CreatePersonDetailsResponse createPersonDetailsResponse = personDetailsClient.createPersonDetailsResponse(PersonDetailsEndPoint, createPersonDetailsRequest, new TokenHeaderRequestCallback(userId, organisationToken));
return createPersonDetailsResponse;
} catch (SoapFaultClientException soapFaultClientException) {
return null;
}
}
@Override
public CheckChangesPersonDetailsResponse checkPersonChanges(String personId, String title, String lastName, String initials, String firstName, String infix, Date dateOfBirth, String streetName, String houseNumber, String houseNumberAddition, String postalCode, String residence, String country, String countryOfBirth, String lastNameOfBirth, String infixOfBirth, String nationality, GenderType gender, String insurancePolicy, String policyNumber, String socialSecurityNumber, Date dateOfDeath, String telephone, String emailAddress) throws DatatypeConfigurationException {
...
}
@Override
public UpdatePersonDetailsResponse updatePersonDetails(String personId, String title, String lastName, String initials, String firstName, String infix, Date dateOfBirth, String streetName, String houseNumber, String houseNumberAddition, String postalCode, String residence, String country, String countryOfBirth, String lastNameOfBirth, String infixOfBirth, String nationality, GenderType gender, String insurancePolicy, String policyNumber, String socialSecurityNumber, Date dateOfDeath, String telephone, String emailAddress) throws DatatypeConfigurationException {
...
}
}
PersonDetailsClientConfiguration
@Configuration
public class PersonDetailsClientConfiguration {
@Bean
public Jaxb2Marshaller marshaller() throws Exception {
Jaxb2Marshaller marshaller = new Jaxb2Marshaller();
marshaller.setContextPath("com.<project_name>.stub");
marshaller.afterPropertiesSet();
return marshaller;
}
@Bean
public WebServiceTemplate webServiceTemplate(Jaxb2Marshaller marshaller) {
WebServiceTemplate webServiceTemplate = new WebServiceTemplate();
webServiceTemplate.setDefaultUri("ENDPOINT_URL");
webServiceTemplate.setMarshaller(marshaller);
webServiceTemplate.setUnmarshaller(marshaller);
return webServiceTemplate;
}
@Bean
public PersonDetailsClient personDetailsClient(Jaxb2Marshaller marshaller) {
PersonDetailsClient personDetailsClient = new PersonDetailsClient();
personDetailsClient.setDefaultUri("ENDPOINT_URL");
personDetailsClient.setMarshaller(marshaller);
personDetailsClient.setUnmarshaller(marshaller);
return personDetailsClient;
}
}
PersonDetailsClient
public class PersonDetailsClient extends WebServiceGatewaySupport {
public GetPersonDetailsResponse getPersonDetailsResponse(String personDetailsEndPoint, GetPersonDetailsRequest getPersonDetailsRequest, TokenHeaderRequestCallback tokenHeaderRequestCallback) {
GetPersonDetailsResponse getPersonDetailsResponse = (GetPersonDetailsResponse) getWebServiceTemplate().marshalSendAndReceive(personDetailsEndPoint, getPersonDetailsRequest, tokenHeaderRequestCallback);
return getPersonDetailsResponse;
}
public CreatePersonDetailsResponse createPersonDetailsResponse (String personDetailsEndPoint, CreatePersonDetailsRequest createPersonDetailsRequest, TokenHeaderRequestCallback tokenHeaderRequestCallback) {
CreatePersonDetailsResponse createPersonDetailsResponse = (CreatePersonDetailsResponse) getWebServiceTemplate().marshalSendAndReceive(personDetailsEndPoint, createPersonDetailsRequest, tokenHeaderRequestCallback);
return createPersonDetailsResponse;
}
public CheckChangesPersonDetailsResponse checkChangesPersonDetailsResponse (String personDetailsEndPoint, CheckChangesPersonDetailsRequest checkChangesPersonDetailsRequest, TokenHeaderRequestCallback tokenHeaderRequestCallback) {
CheckChangesPersonDetailsResponse checkChangesPersonDetailsResponse = (CheckChangesPersonDetailsResponse) getWebServiceTemplate().marshalSendAndReceive(personDetailsEndPoint, checkChangesPersonDetailsRequest, tokenHeaderRequestCallback);
return checkChangesPersonDetailsResponse;
}
public UpdatePersonDetailsResponse updatePersonDetailsResponse (String personDetailsEndPoint, UpdatePersonDetailsRequest updatePersonDetailsRequest, TokenHeaderRequestCallback tokenHeaderRequestCallback) {
UpdatePersonDetailsResponse updatePersonDetailsResponse = (UpdatePersonDetailsResponse) getWebServiceTemplate().marshalSendAndReceive(personDetailsEndPoint, updatePersonDetailsRequest, tokenHeaderRequestCallback);
return updatePersonDetailsResponse;
}
}
pom.xml
<?xml version="1.0" encoding="UTF-8"?>
<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 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.5.4</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<groupId>com.<group_name></groupId>
<artifactId><artifactId></artifactId>
<version>0.0.1-SNAPSHOT</version>
<name><Project_name></name>
<properties>
<java.version>8</java.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-devtools</artifactId>
<scope>runtime</scope>
<optional>true</optional>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-security</artifactId>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-thymeleaf</artifactId>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-oxm</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.ws</groupId>
<artifactId>spring-ws-core</artifactId>
</dependency>
</dependencies>
<distributionManagement>
<snapshotRepository>
<uniqueVersion>false</uniqueVersion>
<id>snapshot</id>
<name>Carewebport Snapshots</name>
<url>https://repo.maven.apache.org/maven2</url>
<layout>default</layout>
</snapshotRepository>
</distributionManagement>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
<plugin>
<groupId>org.jvnet.jaxb2.maven2</groupId>
<artifactId>maven-jaxb2-plugin</artifactId>
<version>0.14.0</version>
<configuration>
<schemaLanguage>WSDL</schemaLanguage>
<generatePackage>com.<project_name>.stub</generatePackage>
<schemas>
<schema>
<url>URL.WSDL</url>
</schema>
</schemas>
</configuration>
<executions>
<execution>
<goals>
<goal>generate</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
1.In sts/eclipse 键入 ctrl+t 并键入 class 名称。如果找到然后记下它来自的 jar 名称让我们说 x。如果在 class 路径上找不到,那么您必须在 class 存在的地方添加依赖项
2 使用任何 zip 提取器打开在目标文件夹下构建的 jar,然后在 WEB-INF/lib 文件夹中检查 jar x 是否在该 x jar 下找到 javax/xml/soap/SOAPException。
这可能是由于您在运行时使用的 Java 版本所致。您必须将 javax ws 包添加为依赖项,因为它不再与较新的 Java 版本捆绑在一起。有关详细信息,请参阅