工程目录:
(一)创建Springboot项目并引入依赖
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web-services</artifactId>
</dependency>
<dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-rt-frontend-jaxws</artifactId>
<version>3.1.12</version>
</dependency>
<dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-rt-transports-http</artifactId>
<version>3.1.12</version>
</dependency>
(二)创建实体类
@Data
public class Weather implements Serializable {
private Long weatherId;
private String city;
private String weather;
public Weather() {
}
public Weather(Long weatherId, String city, String weather) {
this.weatherId = weatherId;
this.city = city;
this.weather = weather;
}
}
(三)编写WebService需要的服务接口和实现