# user-platform **Repository Path**: javadalao/user-platform ## Basic Information - **Project Name**: user-platform - **Description**: No description available - **Primary Language**: Unknown - **License**: Not specified - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2021-02-28 - **Last Updated**: 2021-07-12 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # user-platform ### 作业 #### 第七周作业 **作业步骤** - 到gitee设置中的第三方应用新建应用,回调地址填写:http://localhost:8080/oauth/callback - 将client_id,client_secret配置到user-web模块中的application.properties中 - 启动项目,访问 http://localhost:8080/user-form/login/page - 点击左下角gitee登录,即可跳转到gitee进行授权,授权完成后会重定向到用户信息接口 **源码位置** user-web 模块下的 Oauth2Controller 中 #### 第八周作业 作业源码 ```java @Configuration public class WebSecurityConfig { @Configuration @Order(1) static class Config1 extends WebSecurityConfigurerAdapter { @Override protected void configure(HttpSecurity http) throws Exception { // 首先指定当前地址,为当前地址 /user 路径下的所有的请求配置一个条过滤链 // 当访问/user 路径下的地址 该配置会生效 http.antMatcher("/user/**") .authorizeRequests() .anyRequest().permitAll() .and() .csrf().disable(); } } @Configuration @Order(2) static class Config2 extends WebSecurityConfigurerAdapter { @Override protected void configure(HttpSecurity http) throws Exception { // 同上 http.antMatcher("/user2/**") .authorizeRequests() .anyRequest().permitAll() .and() .csrf().disable(); } } } ``` #### 第九周作业 1. 清除某个 Spring Cache 所有的 Keys 关联的对象 通过给RedisCache分配一个前缀,后续清空该缓存时,只需要清除以该前缀开头的所有key即可 **作业源码** user-web 下的RedisCache中 2. 将 RedisCacheManager 与 @Cacheable 注解打通 ```java @Configuration public class CustomCachingConfigurerSupport extends CachingConfigurerSupport { @Override public CacheManager cacheManager() { return new RedisCacheManager("localhost:6379"); } } ``` 通过自定义CachingConfigurerSupport实现cacheManage方法可以将自定义的CacheManager注入到容器使用 **源码位置** user-web模块下 org.geektimes.cache 包中 #### 第十周作业 作业源码 user-web工程下 org.geektimes.mybatis 包下 #### 第十一周作业 作业源码 user-web 工程下 org.geektimes.hash 包下 #### 第十二周作业 mybatis自动配置工程名称:mybatis-spring-boot-starter mybatis自动配置测试代码在工程:spring-boot-starter-demo下 运行`SpringBootStarterDemoApplication`中的main方法即可 #### 第十三周作业 工程名: spring-cloud-projects/spring-cloud-config #### 第十四周作业 工程-01:spring-cloud-projects/spring-cloud-bus-provider 工程-02:spring-cloud-projects/spring-cloud-bus-client **启动步骤** 1. 首先在项目中配置Redis相关信息,然后启动项目,端口分别是8080,8081 2. 使用接口工具访问:http://localhost:8080/actuator/busenv,请求方法`post`,传参格式 ```json {"name":"name", "value":"value"} ``` 3. 观察控制台日志 #### 第十六周作业 环境信息 OS:win10 编译步骤 1. 创建spring-native项目:spring-boot-native 2. 启动docker 3. 执行命令 `mvn sring-boot:build-image`,项目开始编译打包,信息如下 ```text ... 省略部分日志信息 [INFO] [creator] [/layers/paketo-buildpacks_native-image/native-image/org.geektime.springbootnative.SpringBootNativeApplication:160] (clinit): 951.75 ms, 3.77 GB [INFO] [creator] [/layers/paketo-buildpacks_native-image/native-image/org.geektime.springbootnative.SpringBootNativeApplication:160] (typeflow): 31,868.22 ms, 3.77 GB [INFO] [creator] [/layers/paketo-buildpacks_native-image/native-image/org.geektime.springbootnative.SpringBootNativeApplication:160] (objects): 29,551.25 ms, 3.77 GB [INFO] [creator] [/layers/paketo-buildpacks_native-image/native-image/org.geektime.springbootnative.SpringBootNativeApplication:160] (features): 2,795.37 ms, 3.77 GB [INFO] [creator] [/layers/paketo-buildpacks_native-image/native-image/org.geektime.springbootnative.SpringBootNativeApplication:160] analysis: 66,994.07 ms, 3.77 GB [INFO] [creator] [/layers/paketo-buildpacks_native-image/native-image/org.geektime.springbootnative.SpringBootNativeApplication:160] universe: 1,954.35 ms, 3.77 GB [INFO] [creator] [/layers/paketo-buildpacks_native-image/native-image/org.geektime.springbootnative.SpringBootNativeApplication:160] (parse): 8,129.99 ms, 3.79 GB [INFO] [creator] [/layers/paketo-buildpacks_native-image/native-image/org.geektime.springbootnative.SpringBootNativeApplication:160] (inline): 6,078.98 ms, 4.72 GB [INFO] [creator] [/layers/paketo-buildpacks_native-image/native-image/org.geektime.springbootnative.SpringBootNativeApplication:160] (compile): 52,096.29 ms, 6.87 GB [INFO] [creator] [/layers/paketo-buildpacks_native-image/native-image/org.geektime.springbootnative.SpringBootNativeApplication:160] compile: 69,195.73 ms, 6.87 GB [INFO] [creator] [/layers/paketo-buildpacks_native-image/native-image/org.geektime.springbootnative.SpringBootNativeApplication:160] image: 6,174.43 ms, 6.89 GB [INFO] [creator] [/layers/paketo-buildpacks_native-image/native-image/org.geektime.springbootnative.SpringBootNativeApplication:160] write: 803.94 ms, 6.89 GB [INFO] [creator] # Printing build artifacts to: org.geektime.springbootnative.SpringBootNativeApplication.build_artifacts.txt [INFO] [creator] [/layers/paketo-buildpacks_native-image/native-image/org.geektime.springbootnative.SpringBootNativeApplication:160] [total]: 152,706.95 ms, 6.89 GB [INFO] [creator] Removing bytecode [INFO] [creator] Process types: [INFO] [creator] native-image: /workspace/org.geektime.springbootnative.SpringBootNativeApplication (direct) [INFO] [creator] task: /workspace/org.geektime.springbootnative.SpringBootNativeApplication (direct) [INFO] [creator] web: /workspace/org.geektime.springbootnative.SpringBootNativeApplication (direct) [INFO] [creator] ===> EXPORTING [INFO] [creator] Adding layer 'paketo-buildpacks/ca-certificates:helper' [INFO] [creator] Adding 1/1 app layer(s) [INFO] [creator] Adding layer 'launcher' [INFO] [creator] Adding layer 'config' [INFO] [creator] Adding layer 'process-types' [INFO] [creator] Adding label 'io.buildpacks.lifecycle.metadata' [INFO] [creator] Adding label 'io.buildpacks.build.metadata' [INFO] [creator] Adding label 'io.buildpacks.project.metadata' [INFO] [creator] Adding label 'org.opencontainers.image.title' [INFO] [creator] Adding label 'org.opencontainers.image.version' [INFO] [creator] Adding label 'org.springframework.boot.version' [INFO] [creator] Setting default process type 'web' [INFO] [creator] Saving docker.io/library/spring-boot-native:0.0.1-SNAPSHOT... [INFO] [creator] *** Images (e4a641133384): [INFO] [creator] docker.io/library/spring-boot-native:0.0.1-SNAPSHOT [INFO] [creator] Adding cache layer 'paketo-buildpacks/graalvm:jdk' [INFO] [creator] Adding cache layer 'paketo-buildpacks/native-image:native-image' [INFO] [INFO] Successfully built image 'docker.io/library/spring-boot-native:0.0.1-SNAPSHOT' [INFO] [INFO] ------------------------------------------------------------------------ [INFO] BUILD SUCCESS [INFO] ------------------------------------------------------------------------ [INFO] Total time: 06:22 min [INFO] Finished at: 2021-06-20T19:12:20+08:00 [INFO] Final Memory: 126M/904M [INFO] ------------------------------------------------------------------------ ``` 4. 执行命令`docker run -itd -p 8080:8080 spring-boot-native:0.0.1-SNAPSHOT` 运行容器 项目启动日志如下 ```text 2021-06-20 11:14:35.700 INFO 1 --- [ main] o.s.nativex.NativeListener : This application is bootstrapped with code generated with Spring AOT . ____ _ __ _ _ /\\ / ___'_ __ _ _(_)_ __ __ _ \ \ \ \ ( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \ \\/ ___)| |_)| | | | | || (_| | ) ) ) ) ' |____| .__|_| |_|_| |_\__, | / / / / =========|_|==============|___/=/_/_/_/ :: Spring Boot :: (v2.5.1) 2021-06-20 11:14:35.701 INFO 1 --- [ main] o.g.s.SpringBootNativeApplication : Starting SpringBootNativeApplication using Java 1.8.0_292 on aba315278c71 with PID 1 (/workspace/org.geektime.springbootnative.SpringBootNativeApplication started by cnb in /workspace) 2021-06-20 11:14:35.701 INFO 1 --- [ main] o.g.s.SpringBootNativeApplication : No active profile set, falling back to default profiles: default 2021-06-20 11:14:35.740 INFO 1 --- [ main] o.s.b.w.embedded.tomcat.TomcatWebServer : Tomcat initialized with port(s): 8080 (http) Jun 20, 2021 11:14:35 AM org.apache.coyote.AbstractProtocol init INFO: Initializing ProtocolHandler ["http-nio-8080"] Jun 20, 2021 11:14:35 AM org.apache.catalina.core.StandardService startInternal INFO: Starting service [Tomcat] Jun 20, 2021 11:14:35 AM org.apache.catalina.core.StandardEngine startInternal INFO: Starting Servlet engine: [Apache Tomcat/9.0.46] Jun 20, 2021 11:14:35 AM org.apache.catalina.core.ApplicationContext log INFO: Initializing Spring embedded WebApplicationContext 2021-06-20 11:14:35.744 INFO 1 --- [ main] w.s.c.ServletWebServerApplicationContext : Root WebApplicationContext: initialization completed in 42 ms Jun 20, 2021 11:14:35 AM org.apache.coyote.AbstractProtocol start INFO: Starting ProtocolHandler ["http-nio-8080"] 2021-06-20 11:14:35.768 INFO 1 --- [ main] o.s.b.w.embedded.tomcat.TomcatWebServer : Tomcat started on port(s): 8080 (http) with context path '' 2021-06-20 11:14:35.769 INFO 1 --- [ main] o.g.s.SpringBootNativeApplication : Started SpringBootNativeApplication in 0.073 seconds (JVM running for 0.075) Jun 20, 2021 11:14:53 AM org.apache.catalina.core.ApplicationContext log INFO: Initializing Spring DispatcherServlet 'dispatcherServlet' 2021-06-20 11:14:53.862 INFO 1 --- [nio-8080-exec-1] o.s.web.servlet.DispatcherServlet : Initializing Servlet 'dispatcherServlet' 2021-06-20 11:14:53.862 INFO 1 --- [nio-8080-exec-1] o.s.web.servlet.DispatcherServlet : Completed initialization in 0 ms ``` 5. 访问链接:`http://localhost:8080` 出现Hello World **暂时没有搞定通过Dockerfile的方式实现**