您的位置:首页 > 科技 > IT业 > 品牌vi设计方案_精品网站建设费用_东莞网络推广优化排名_企业网络推广平台

品牌vi设计方案_精品网站建设费用_东莞网络推广优化排名_企业网络推广平台

2024/11/17 16:53:38 来源:https://blog.csdn.net/m0_46695127/article/details/143087712  浏览:    关键词:品牌vi设计方案_精品网站建设费用_东莞网络推广优化排名_企业网络推广平台
品牌vi设计方案_精品网站建设费用_东莞网络推广优化排名_企业网络推广平台

文章目录

  • cubemall-product
    • Blog.java
    • SearchFeignTest.java
    • SearchFeign.java
    • pom.xml
    • application.yml
  • cubemall-search
    • HelloController.java

cubemall-product

Blog.java

package com.xd.cubemall.product.entity;import lombok.Data;@Data
public class Blog {private Long id;private String title;private String content;private String comment;private String mobile;
}

SearchFeignTest.java

package com.xd.cubemall.feign;import com.xd.cubemall.common.utils.R;
import com.xd.cubemall.product.CubemallProductApplication;
import com.xd.cubemall.product.entity.Blog;
import com.xd.cubemall.product.feign.SearchFeign;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringRunner;@RunWith(SpringRunner.class)
@SpringBootTest(classes = CubemallProductApplication.class)
public class SearchFeignTest {@Autowiredprivate SearchFeign searchFeign;@Testpublic void testSayHello() {R r = searchFeign.sayHello("tom");System.out.println(r);}@Testpublic void testSayHello2() {R r = searchFeign.sayHello2("张三");System.out.println(r);}@Testpublic void testGetBlog() {Blog blog = new Blog();blog.setId(1l);blog.setTitle("hello");blog.setContent("world");R r = searchFeign.getBlog(blog);System.out.println(r);}@Testpublic void testGetBlog2() {Blog blog = new Blog();blog.setId(1l);blog.setTitle("hello");blog.setContent("world");R r = searchFeign.getBlog2(blog,"aaa");System.out.println(r);}}

SearchFeign.java

package com.xd.cubemall.product.feign;import com.xd.cubemall.common.utils.R;
import com.xd.cubemall.product.entity.Blog;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.*;@FeignClient("cubemall-search")
public interface SearchFeign {@GetMapping("hello/{name}")R sayHello(@PathVariable("name") String name);@GetMapping("hello")R sayHello2(@RequestParam("name") String name);@PostMapping("/blog")public R getBlog(@RequestBody Blog blog);@PostMapping("/blog2")public R getBlog2(@RequestBody Blog blog, @RequestParam("name") String name);@GetMapping("/spuinfo/putonsale/{spuId}")R putOnSale(@PathVariable("spuId") Long spuId);
}

pom.xml

        <dependency><groupId>org.springframework.cloud</groupId><artifactId>spring-cloud-starter-openfeign</artifactId></dependency>

application.yml

spring:cloud:nacos:discovery:server-addr: 127.0.0.1:8848ip: 127.0.0.1application:name: cubemall-product

cubemall-search

HelloController.java

package com.xd.cubemall.search.controller;import com.xd.cubemall.common.utils.R;
import com.xd.cubemall.search.model.Blog;
import org.springframework.web.bind.annotation.*;@RestController
public class HelloController {@GetMapping("hello/{name}")public R sayHello(@PathVariable String name) {return R.ok("hello" + name);}//http://localhost:8082/hello?name=lisi@GetMapping("hello")public R sayHello2(String name) {return R.ok("hello" + name);}@PostMapping("/blog")public R getBlog(@RequestBody Blog blog) {blog.setComment("接收到blog对象");blog.setMobile("111111");return R.ok(blog);}@PostMapping("/blog2")public R getBlog2(@RequestBody Blog blog, String name) {blog.setComment(name);blog.setMobile("222222");return R.ok(blog);}}

版权声明:

本网仅为发布的内容提供存储空间,不对发表、转载的内容提供任何形式的保证。凡本网注明“来源:XXX网络”的作品,均转载自其它媒体,著作权归作者所有,商业转载请联系作者获得授权,非商业转载请注明出处。

我们尊重并感谢每一位作者,均已注明文章来源和作者。如因作品内容、版权或其它问题,请及时与我们联系,联系邮箱:809451989@qq.com,投稿邮箱:809451989@qq.com