newbee-mall
-
WebMvcConfigurationSupport和WebMvcCofigurer的区别
SpringBoot2.0之后
WebMvcConfigurerAdapter
过时,取而代之的是WebMvcConfigurationSupport
查看源码发现:
WebMvcConfigurerAdapter
只是对WebMvcCofigurer
的空实现,而WebMvcConfigurationSupport
的实现的方法更全面。但是继承WebMvcConfigurationSupport
会发现Spring Boot的WebMvc自动配置失效(WebMvcAutoConfiguration
自动化配置),导致无法视图解析器无法解析并返回到对应的视图WebMvcConfigurationSupport–>不需要返回逻辑视图,可以选择继承此类
WebMvcCofigurer–>返回逻辑视图,可以选择实现此方法
forum-java
forum-starter
-
SpringBootServletInitializer
是一个支持Spring Boot的SpringWebApplicationInitializer
实现。除了配置Spring的Dispatcher-Servlet,SpringBootServletInitialize
r还会在Spring应用程序上下文里查找Filter、Servlet或ServletContextInitializer
类型的Bean,把它们绑定到Servlet容器里。要使用SpringBootServletInitializer
,只需创建一个子类,覆盖configure()方法来指定Spring配置类。@EnableScheduling @SpringBootApplication(scanBasePackages = "pub.developers.forum") @MapperScan(value = {"pub.developers.forum.infrastructure.dal.dao"}) public class ForumJavaApplication extends SpringBootServletInitializer { public static void main(String[] args) { SpringApplication.run(ForumJavaApplication.class, args); } @Override protected SpringApplicationBuilder configure(SpringApplicationBuilder builder) { return builder.sources(ForumJavaApplication.class); } }
-
@EnableScheduling
注解对应的内容如下:@Target(ElementType.TYPE) @Retention(RetentionPolicy.RUNTIME) @Import(SchedulingConfiguration.class) @Documented public @interface EnableScheduling { }
由上可以看到实际上是
SchedulingConfiguration.class
类实现了Spring
的任务调度框架级功能。该配置类仅仅是定义了ScheduledAnnotationBeanPostProcessor
的实例。Spring 的调度功能由该实例进行配置。定时任务在配置类上添加
@EnableScheduling
开启对定时任务的支持,在相应的方法上添加@Scheduled
声明需要执行的定时任务。@Scheduled
@Scheduled注解各参数详解 -
MyTest.java
-
pom.xml
spring-boot-maven-plugin<plugin> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-maven-plugin</artifactId> <configuration> <jvmArguments>-Dfile.encoding=UTF-8</jvmArguments> <!--SpringBoot 2.5.3在打包的时候已经排除processor(用于自定义属性的提示),不需要添加插件--> <excludes> <exclude> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-configuration-processor</artifactId> </exclude> </excludes> </configuration> <!-- mvn spring-boot:repackage --> <executions> <execution> <goals> <goal>repackage</goal> </goals> </execution> </executions> </plugin>
forum-domain
@Builder
详解Lombok中的@Builder用法
forum-common
-
package pub.developers.forum.common.model
- PageRequest
- PageResult
-
package pub.developers.forum.common.support
-
AvatarUtil
String.format()
JAVA字符串格式化——String.format()的使用 -
CheckUtil
// 格式化 PARAM_CHECK_ERROR(9995, "请求参数不能为空:{0}") MessageFormat.format(ErrorCodeEn.PARAM_CHECK_ERROR.getMessage(), message)
-
EventBus Spring中的InitializingBean的使用详解
-
ExecutorFactory 创建ThreadFactory的集中常见方法
-
GlobalViewConfig
// GitHub登录 private String githubClientId; private String githubOauthUrl; public String getGithubOauthUrl() { // https://github.com/login/oauth/authorize?client_id=5c00b7f2065217732aa3&scope=user return "https://github.com/login/oauth/authorize?client_id=" + githubClientId + "&scope=user"; }
-
LogUtil
-
RequestContext
-
RestTemplateConfig RestTemplate使用教程 SSLContext
-
SafesUtil
-
StringUtil
-
forum-infrastructure
-
package pub.developers.forum.infrastructure.audit
- PostsAuditTask
-
package pub.developers.forum.infrastructure.cache
- DbCacheServiceImpl
-
package pub.developers.forum.infrastructure.file
- QiNiuFileServiceImpl
-
package pub.developers.forum.infrastructure.github
- GithubServiceImpl Github授权登录
-
package pub.developers.forum.infrastructure.mail
-
Mail163ServiceImpl
<dependency> <groupId>com.sun.mail</groupId> <artifactId>javax.mail</artifactId> <version>1.6.2</version> </dependency>
-
-
package pub.developers.forum.infrastructure.search
- DbSearchServiceImpl
-
package pub.developers.forum.infrastructure.transfer
- PostsTransfer 利用继承对各种方法的抽取
-
pom.xml
<!--添加编译参数--> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-compiler-plugin</artifactId> <version>3.8.1</version> <configuration> <compilerArgs> <arg>--add-exports</arg> <arg>java.base/com.sun.net.ssl.internal.ssl=ALL-UNNAMED</arg> </compilerArgs> </configuration> </plugin>
forum-api
package pub.developers.forum.api.model
- PageRequestModel
@Setter
的使用
- PageRequestModel
forum-app
package pub.developers.forum.app.support
- IsLoginAspect
- LoginUserContext
package pub.developers.forum.app.manager
- AbstractPostsManager delete方法异步任务事务传播 --> 不同线程在独立的事务中 Spring单实例、多线程安全、事务解析
- CommentManager page方法逻辑
forum-facade
-
package pub.developers.forum.facade.aspect
- ExceptionHandlerAndLogAspect
- LoginUserAspect
只会代理在容器中的组件,在本项目中,虽然匹配的是api包下的所有包的所有类的所有方法,但只有service包下接口的实现类在容器中,所以实际代理的是所有实现类的方法
forum-portal
-
package pub.developers.forum.portal.support
- CorsInterceptor
- GlobalViewInterceptor
- GetMappingAspect
- ResponseBodyAspect
- WebConfigurer
- WebContext
-
@Value
注解- WebUtil