springcloud gateway的工程需要单独,不要使用父类的依赖

 

 

 很简单的结构,简单使用这些就够了

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">

4.0.0

spring-boot-starter-parent

org.springframework.boot

2.3.4.RELEASE

com.gateway

gateway-service

1.0-SNAPSHOT

org.springframework.cloud

spring-cloud-commons

org.springframework.cloud

spring-cloud-starter-netflix-eureka-client

org.springframework.cloud

spring-cloud-starter-gateway

org.springframework.boot

spring-boot-starter-webflux

org.springframework.cloud

spring-cloud-dependencies

Hoxton.RELEASE

pom

import

org.apache.maven.plugins

maven-compiler-plugin

1.8

1.8

utf-8

org.springframework.boot

spring-boot-maven-plugin

下面是配置文件

#eureka server服务端口

server:

port: 9000

spring:

application:

name: gateway-service # 应用名称,应用名称会在Eureka中作为服务名称

cloud:

#getway配置

##### 动态路由设置时,uri以 lb: //开头(lb代表从注册中⼼获取服务),后⾯是需要转发到的服务名称

gateway:

routes: # 路由可以有多个

- id: service-router1 # 我们⾃定义的路由 ID,保持唯⼀

#uri: http://127.0.0.1:8082 # ⽬标服务地址 部署多实例) 动态路由:uri配置的应该是⼀个服务名称,⽽不应该是⼀个具体的服务实例的地址

uri: lb://login-service # ⽬标服务地址 部署多实例) 动态路由:uri配置的应该是⼀个服务名称,⽽不应该是⼀个具体的服务实例的地址

# gateway⽹关从服务注册中⼼获取实例信息然后负载后路由

predicates: #断⾔:路由条件,Predicate 接受⼀个输⼊参数,返回⼀个布尔值结果。该接⼝包含多种默 认⽅法来将 Predicate 组合成其他复杂的逻辑(⽐如:与,或,⾮)。

- Path=/**

如果想使用application.properties这种形式,参考下图

 

说明下- Path=/login/**,这样把路径可以配置的更加细化些

package com.gateway;

import org.springframework.boot.SpringApplication;

import org.springframework.boot.autoconfigure.SpringBootApplication;

import org.springframework.cloud.client.discovery.EnableDiscoveryClient;

/**

* @Description

* @Author qiuxie

* @Date 2021/8/3 0:10

*/

@SpringBootApplication

@EnableDiscoveryClient

public class GateWayApplication {

public static void main(String[] args) {

SpringApplication.run(GateWayApplication.class,args);

}

}

使用springcloud需要一个eureka注册中心,一个服务提供者

 

下面依次给出注册中心的

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">

homework-parent

com.parent

1.0-SNAPSHOT

4.0.0

com.eureka

eureka-service

org.springframework.cloud

spring-cloud-starter-netflix-eureka-server

 

 

package com.eureka;

import org.springframework.boot.SpringApplication;

import org.springframework.boot.autoconfigure.SpringBootApplication;

import org.springframework.cloud.netflix.eureka.server.EnableEurekaServer;

/**

* @Description

* @Author qiuxie

* @Date 2021/7/30 0:09

*/

@SpringBootApplication

@EnableEurekaServer

public class EurekaOneApplication {

public static void main(String[] args) {

SpringApplication.run(EurekaOneApplication.class,args);

}

}

server.port=8761

spring.application.name=eureka-service

eureka.instance.hostname=localhost

eureka.client.service-url.defaultZone=http://${eureka.instance.hostname}:8762

eureka.client.register-with-eureka=false

eureka.client.fetch-registry=false

接下来是服务提供者

 

 

package com.login.controller.front;

import org.springframework.stereotype.Controller;

import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;

/**

* @Description

* @Author qiuxie

* @Date 2021/7/24 0:10

*/

@Controller

public class LoginController {

@RequestMapping("/login")

public String login(){

return "login/login";

}

// 跳转注册页面

@RequestMapping("/toRe")

public String toRe() {

return "login/re";

}

}

package com.login;

import org.springframework.boot.SpringApplication;

import org.springframework.boot.autoconfigure.SpringBootApplication;

import org.springframework.cloud.client.discovery.EnableDiscoveryClient;

/**

* @Description

* @Author qiuxie

* @Date 2021/7/24 0:09

*/

@SpringBootApplication

@EnableDiscoveryClient

public class LoginApplication {

/**

* 定义管理员名称

*/

public static String userAdmin = "";

public static void main(String[] args) {

SpringApplication.run(LoginApplication.class,args);

}

}

content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no">

[[#{text.suffix}]]

不忘初心


class="am-icon-user am-icon-sm am-icon-fw">


class="am-icon-lock am-icon-sm am-icon-fw">


注册

 

注册-[[#{text.suffix}]]


用户名

密码

密码

邮箱

验证码

返回

pom文件

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">

homework-parent

com.parent

1.0-SNAPSHOT

4.0.0

com.login

login-service

org.springframework.cloud

spring-cloud-starter-netflix-eureka-client

org.springframework.boot

spring-boot-starter-web

org.springframework.boot

spring-boot-starter-thymeleaf

org.springframework.boot

spring-boot-devtools

true

浏览器输入http://127.0.0.1:9000/login

 

 

 

app.css

html {

width:100%;

height:100%;

}

.bg-grey {

background-color: #f7f7f7

}

body {

width:100%;

height:100%;

}

.log {

width:100%;

height:100%;

background:url(/img/f10.jpg) #000 no-repeat;

/* background:#D2B48C; */

background-size:100% 100%;

color:#ffffff;

}

@media only screen and (max-width:640px) {

.log {

background-size:180% 100%;

background-position:top right;

}

.log-title {

display:none;

}

}

.log-title {

font-size:4rem;

}

.log-content {

margin-top:15%;

text-align:center;

}

.log-button {

background-color:transparent;

border-radius:8px;

border:2px solid #ffffff;

display:inline-block;

cursor:pointer;

color:#ffffff;

text-decoration:none;

text-shadow:0px 1px 0px #2f6627;

}

.log-button:hover {

background-color:#0e90d2;

border:2px solid #0e90d2;

color:#ffffff;

}

.log-button:active {

position:relative;

top:1px;

}

.log-header,.log-re {

background-color:transparent;

position:absolute;

top:0;

color:#ffffff;

}

.log-header {

display: block;

height: 50px;

width: 165px;

margin-left:10%;

text-indent: -9999px;

background-size: 125px 24px;

}

.log-header:hover {

height: 50px;

width: 165px;

margin-left:10%;

text-indent: -9999px;

background: url(http://s.amazeui.org/media/i/brand/amazeui-cw.png) left center no-repeat;

background-size:125px 24px;

}

.log a {

color:#fff;

}

.log-re {

right:10%;

top:1%;

}

.log-icon {

background-color:transparent;

color:#ffffff;

}

.log-animation-delay {

-webkit-animation-delay: 200ms;

animation-delay: 200ms;

}

.log-animation-delay-a {

-webkit-animation-delay: 300ms;

animation-delay: 300ms;

}

.log-animation-delay-b {

-webkit-animation-delay: 500ms;

animation-delay: 500ms;

}

.log-alert {

clear:both;

width:100%;

height:28px;

line-height:28px;

padding-top:0;

position:absolute;

top:20px;

left:0;

display:block;

}

.log-footer {

position:absolute;

bottom:10px;

width:100%;

text-align:center;

}

/**

* blog css

* a:hover: #10D07A

* 基本色:#333

* 或者 #3d3d3d

* bgcolor:#10D07A , color:#fff

* blog-color 单独的颜色突出

* .blog-bor border:1px solid #e5e5e5

* css复用 与 规范化

*/

a:hover {

color:#10D07A;

}

.blog-header {

margin-top:3rem;

}

@media only screen and (max-width:640px) {

.blog-header {

margin-top:1rem;

}

.blog-nav li {

text-align:center;

}

}

#blog hr {

margin:0.6rem 0;

}

.blog-nav {

padding:0 1.3rem;

}

.blog-nav li a:hover{

background-color:#fff;

color:#10D07A;

}

.blog-button {

width:95%;

height:100%;

margin-left:1.5rem;

background-color:#10D07A;

}

.am-dropdown-content li a{

background-color:transparent;

}

.am-dropdown-content li a:hover {

background-color:#10D07A;

}

.blog-text-center {

text-align:center;

}

.blog-bor {

border:1px solid #e5e5e5;

}

.am-topbar-nav>li.am-active>a, .am-topbar-nav>li.am-active>a:focus, .am-topbar-nav>li.am-active>a:hover {

border-radius: 0;

color: #10D07A;

background: 0 0;

text-align:center;

}

.am-topbar-nav>li>a:hover:after {

opacity: 0;

}

@media only screen and (min-width: 641px) {

.am-topbar-nav>li.am-active>a:after {

opacity: 0;

}

}

@media only screen and (min-width: 1200px) {

.blog-fixed {

max-width: 1200px;

}

}

.blog-entry-img {

padding:0;

max-width:100%;

height:auto;

}

.blog-entry-article {

margin:3rem 0;

padding-bottom: 3rem;

border-bottom: 1px solid #e5e5e5;

}

@media only screen and (max-width:640px) {

.blog-entry-article {

padding-bottom:1rem;

text-align:center;

}

}

.blog-entry-text {

padding:0 1rem;

}

.blog-entry-text h1 {

margin-top:0;

color:#3d3d3d;

}

.blog-sidebar {

margin-top:3rem;

padding:0 1.5rem 0 3rem;

}

.blog-title {

margin-top:-1.5rem;

}

.blog-title span{

background-color:#fff;

padding:0 1.5rem;

}

.blog-sidebar-widget {

padding:0 2rem;

margin-bottom:4rem;

text-align:center;

}

h1 span{

color:#333;

}

.blog-icon {

width:3.4rem;

border:1px solid #e5e5e5;

padding:0.5rem;

color:#3d3d3d;

}

.blog-icon:hover {

color:#fff;

background:#10D07A;

border:1px solid #10D07A;

}

.blog-color {

/**color:#10D07A;**/

}

.blog-continue {

color:#000;

border:0.2rem solid gray;

padding:0.5rem 1rem;

font-weight:bold;

display:none;

}

.blog-continue:hover {

background-color:#10D07A;

color:#fff;

border:0.1rem #fff;

}

.blog-tag {

background:#F3F3F3;

margin:0.15rem 0.15rem;

line-height:2.5rem;

float:left;

border: 1px solid #eee;

padding:0.2rem 0.8rem 0.2rem 0.8rem;

}

.blog-tag:hover {

background:#10D07A;

color:#fff;

}

.blog-clear-margin {

margin-left:0rem !important;

margin-right:0rem !important;

}

.blog-clear-padding {

padding:0 0 1.5rem 0 !important;

}

.blog-tag-left {

text-align:left;

}

.blog-footer {

padding:3rem 0 2rem 0;

margin-top:5rem;

background-color:#252525;

color:#fff !important

}

.blog-footer-padding {

padding:3rem 0;

}

.blog-footer a{

color:#fff;

}

.blog-footer span {

color:#fff;

}

/**

* blog-article-sidebar

*

*/

.blog-article-p {

margin:3rem 0;

}

.blog-author-img {

width:8rem;

height:8rem;

}

@media only screen and (max-width:641px) {

.blog-author-img {

width:6rem;

height:6rem;

}

}

.blog-article-margin {

margin:3rem 0;

}

.blog-clear-left {

padding-left: 0;

}

.blog-clear-right {

padding-right:0;

}

.blog-slider-desc {

width:50%;

height:50%;

overflow:hidden;

border:0.3rem solid #fff;

position:absolute;

left:50%;

top:50%;

transform:translate(-50%,-50%);

-webkit-transform:translate(-50%,-50%);;

background-color:transparent;

}

.blog-slider-con {

position:absolute;

left:0.5%;

top:1%;

width:99%;

height:98%;

border:0.3rem solid #fff;

padding:3rem 8rem;

background-color:#fff;

}

/**

* bug:

* width:100%; height:100%;

* margin: 1% 或者 1rem ;

* 此处的定位出现问题。

*/

.blog-h-margin {

margin:0;

}

.am-slider-carousel li {

margin-right: 25px;

}

.blog-comment {

padding-left:0.625rem;

}

.img-layout {

width:300px;

height:200px;

}

#container {

width: 100%;

margin: auto;

}

#container div {

-webkit-box-shadow: 0 4px 15px -5px #555;

box-shadow: 0 4px 15px -5px #555;

background-color: #fff;

width:220px;

padding:2px;

margin:5px;

}

#container > div img {

padding: 0px;

display: block;

width: 100%;

}

.time-year {

margin-bottom:3rem;

margin-top:3rem;

}

.timeline-year li {

list-style: none;

}

.timeline-span {

border-left:2px solid #10D07A;

}

amazeui.min.css

 

好文链接

评论可见,请评论后查看内容,谢谢!!!评论后请刷新页面。