11.认证服务-初始化
一、创建认证模块
1.1 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>
<artifactId>guli-mall</artifactId>
<groupId>com.zsy</groupId>
<version>0.0.1-SNAPSHOT</version>
</parent>
<artifactId>mall-auth-server</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>mall-auth-server</name>
<description>认证服务(社交登录、Oauth2.0、单点登录)</description>
<dependencies>
<dependency>
<groupId>com.zsy</groupId>
<artifactId>mall-common</artifactId>
<exclusions>
<exclusion>
<groupId>com.baomidou</groupId>
<artifactId>mybatis-plus-boot-starter</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-thymeleaf</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-devtools</artifactId>
<scope>runtime</scope>
<optional>true</optional>
</dependency>
</dependencies>
</project>
1.2 application.yaml
spring:
application:
name: mall-auth-server
cloud:
nacos:
discovery:
server-addr: 192.168.163.131:8848
thymeleaf:
cache: false
server:
port: 20000
1.3 主启动类
package com.zsy.auth;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
import org.springframework.cloud.openfeign.EnableFeignClients;
/**
* @author ZSY
*/
@EnableFeignClients
@EnableDiscoveryClient
@SpringBootApplication
public class MallAuthServerApplication {
public static void main(String[] args) {
SpringApplication.run(MallAuthServerApplication.class, args);
}
}
1.4启动验证
启动服务,发现服务注册进 Nacos
二、页面及域名访问初始化
2.1 修改hosts实现域名访问
# guli mall #
192.168.163.131 gulimall.com
192.168.163.131 search.gulimall.com
192.168.163.131 item.gulimall.com
192.168.163.131 auth.gulimall.com
2.2 配置网关转发域名
- id: mall_auth_route
uri: lb://mall-auth-server
predicates:
- Host=auth.gulimall.com
2.3 引入登录页面
将资料高级篇登录页面和注册页面放到 templates 下,静态文件可以选择 Nginx 动静分离配置,这里采用直接引用的方式。最终目录:
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 分享一个免费、快速、无限量使用的满血 DeepSeek R1 模型,支持深度思考和联网搜索!
· 基于 Docker 搭建 FRP 内网穿透开源项目(很简单哒)
· ollama系列01:轻松3步本地部署deepseek,普通电脑可用
· 25岁的心里话
· 按钮权限的设计及实现