2.2.1.RELEASE
,并引入Common服务依赖,因为不操作数据库,所以排除mybaitsplus依赖<parent> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-parent</artifactId> <version>2.2.1.RELEASE</version> <relativePath/> <!-- lookup parent from repository --> </parent> <properties> <java.version>1.8</java.version> <spring-cloud.version>Hoxton.RELEASE</spring-cloud.version> </properties> <dependency> <groupId>com.achang.achangmall</groupId> <artifactId>achangmall-common</artifactId> <version>0.0.1-SNAPSHOT</version> <exclusions> <exclusion> <groupId>com.baomidou</groupId> <artifactId>mybatis-plus-boot-starter</artifactId> </exclusion> </exclusions> </dependency>
spring.application.name=achang-auth-server spring.cloud.nacos.server-addr=127.0.0.1:8848 server.port=20000 spring.thymeleaf.cache=false
@EnableFeignClients @EnableDiscoveryClient @SpringBootApplication(exclude = DataSourceAutoConfiguration.class) public class AchangAuthServerApplication { public static void main(String[] args) { SpringApplication.run(AchangAuthServerApplication.class, args); } }
192.168.109.101 auth.achangmall.com
修改reg.html、login.html里面的路径引用
添加网关转发配置,achangmall-gateway/src/main/resources/application.yml
- id: auth_route uri: lb://achang-auth-server predicates: - Host=auth.achangmall.com
访问http://auth.achangmall.com/
,访问成功!!!
@Controller public class LoginController { @GetMapping("/login.html") public String loginPage(){ return "login"; } @GetMapping("/reg.html") public String register(){ return "reg"; } }
achang-auth-server/src/main/resources/templates/login.html
achang-auth-server/src/main/resources/templates/reg.html
<a id="sendCode">发送验证码</a>
$(function (){ $("#sendCode").click(function (){ if ($(this).hasClass("disabled")){ //todo 发送手机验证码业务 }{ timeoutChangeSytle() } }); }) var num = 60; function timeoutChangeSytle(){ $("#sendCode").attr("class","disabled") if (num==0){ $("#sendCode").text("发送验证码") num = 60; $("#sendCode").attr("class","") }else { var str = num+"后再次发送" $("#sendCode").text(str) setTimeout("timeoutChangeSytle()",1000) } num--; }
视图映射
com.achang.achangmall.auth.conf.AchangWebConfig
@Configuration public class AchangWebConfig implements WebMvcConfigurer { @Override public void addViewControllers(ViewControllerRegistry registry) { registry.addViewController("/login.html").setViewName("login"); registry.addViewController("/reg.html").setViewName("reg"); } }