chenshurui 2019-06-28
文章数:菜单文章都没更新完
搭建eureka注册中心 (请先阅读此文章) https://segmentfault.com/a/11...
搭建Beans编写Token解析注解 https://segmentfault.com/a/11...
搭建权限管理系统 https://segmentfault.com/a/11...
搭建后台管理系统 https://segmentfault.com/a/11...
前端Fetch请求封装 https://segmentfault.com/a/11...
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 http://maven.apache.org/xsd/maven-4.0.0.xsd"> <modelVersion>4.0.0</modelVersion> <groupId>com.customer</groupId> <artifactId>customer</artifactId> <version>0.0.1-SNAPSHOT</version> <packaging>jar</packaging> <name>customer</name> <description>customer project for Spring Boot</description> <parent> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-parent</artifactId> <version>1.5.6.RELEASE</version> <relativePath/> <!-- lookup parent from repository --> </parent> <properties> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding> <java.version>1.8</java.version> <spring-cloud.version>Camden.SR6</spring-cloud.version> </properties> <dependencies> <dependency> <groupId>com.server</groupId> <artifactId>beans</artifactId> <version>1.0-SNAPSHOT</version><!--这是我的beans项目--> </dependency> <dependency> <groupId>org.springframework.cloud</groupId> <artifactId>spring-cloud-starter-config</artifactId> </dependency> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-security</artifactId> </dependency> <dependency> <groupId>org.springframework.cloud</groupId> <artifactId>spring-cloud-starter-eureka</artifactId> </dependency> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-websocket</artifactId> </dependency> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-devtools</artifactId> <optional>true</optional> </dependency> <dependency> <groupId>org.springframework.cloud</groupId> <artifactId>spring-cloud-starter-feign</artifactId> </dependency> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-actuator</artifactId> </dependency> <dependency> <groupId>org.springframework.cloud</groupId> <artifactId>spring-cloud-starter-eureka-server</artifactId> </dependency> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-test</artifactId> <scope>test</scope> </dependency> <!-- https://mvnrepository.com/artifact/mysql/mysql-connector-java --> <dependency> <groupId>mysql</groupId> <artifactId>mysql-connector-java</artifactId> <version>8.0.11</version> </dependency> <!-- SpringData-Jpa依赖--> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-data-jpa</artifactId> </dependency> </dependencies> <dependencyManagement> <dependencies> <dependency> <groupId>org.springframework.cloud</groupId> <artifactId>spring-cloud-dependencies</artifactId> <version>${spring-cloud.version}</version> <type>pom</type> <scope>import</scope> </dependency> </dependencies> </dependencyManagement> <build> <plugins> <plugin> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-maven-plugin</artifactId> </plugin> </plugins> </build> </project>启动类
@SpringBootApplication @EnableEurekaClient @EnableDiscoveryClient @EnableFeignClients public class CustomerApplication { public static void main(String[] args) { SpringApplication.run(CustomerApplication.class, args); } }使用权限管理系统服务类
@FeignClient(value = "AUS") public interface AuthorityServer { @RequestMapping(value = "/auth/login",method = RequestMethod.POST) String loginAuthentication(@RequestBody UserEntity user); @RequestMapping(value = "/auth/token",method = RequestMethod.GET) String getResourceAuthentication(@RequestParam(value = ParameterNames.ACCESS_TOKEN) String token); @RequestMapping(value = "/auth/sign",method = RequestMethod.POST) String userSignIn(@RequestBody UserEntity user); @RequestMapping(value = "/auth/update",method = RequestMethod.POST) String userUpdate(@RequestBody UserEntity user); @RequestMapping(value = "/api/verify",method = RequestMethod.GET) String getResourcePermissions(@RequestParam(value = ParameterNames.ACCESS_TOKEN)String token,@RequestParam(ParameterNames.CODE) String app,@RequestParam(ParameterNames.PATH) String path); } 》》例子: "使用该类直接调方法传参就可以了" @Autowired private AuthorityServer authorityServer; authorityServer.loginAuthentication(bean);