1. 程式人生 > >spring boot配置service發布服務

spring boot配置service發布服務

too local can word oot servlet init except def

在application.yml中配置

server:
  port: 8080
  context-path: /crm
spring:
  datasource:
    driver-class-name: com.mysql.jdbc.Driver
    url: jdbc:mysql://localhost:3306/crm
    username: root
    password: 136735
  jpa:
    show-sql: true
  jackson:
    default-property-inclusion: non_null
  devtools:
    restart:
      enabled: 
true cxf: path: /services #使用service發布服務,需要在/crm後面加上/service servlet.init: service-list-path: /info jaxrs: component-scan: true

service發布服務

package top.kylewang.crm.controller;

import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.ResponseBody; import javax.ws.rs.Consumes; import javax.ws.rs.GET; import javax.ws.rs.Path; @Path("path") @Service @Transactional(rollbackFor = Exception.class) public class TestPath { @Path("/p1") @GET @Consumes({"application/xml", "application/json"})
public String getString() { return "path"; } }

訪問 http://localhost:8080//crm/services/path/p1

返回path

spring boot配置service發布服務