分类
devops

spring总结

“Path with “WEB-INF” or “META-INF”: [WEB-INF/views/index.jsp]”

"Path with "WEB-INF" or "META-INF": [WEB-INF/views/index.jsp]"

org.springframework.scheduling.concurrent.ExecutorConfigurationSupport

ScheduledExecutorFactoryBean
ThreadPoolExecutorFactoryBean
ThreadPoolTaskExecutor
ThreadPoolTaskScheduler

@Controller返回json

使用@ResponseBody或者返回ResponseEntity类

@Controller 返回string 默认是返回view的名字,想要直接返回json则需要@ResponseBody

    @GetMapping("/map")
    @ResponseBody
    public java.util.Map<String,String> test(){
        java.util.Map<String,String> map = new HashMap<>();
        map.put("hello","hello");
        return map;
    }

@RestController返回页面

@RestController默认返回json,想要返回页面则需要方法体返回ModelAndView

    @GetMapping("foo")
    public ModelAndView foo(){
        ModelAndView modelAndView = new ModelAndView();
        modelAndView.setViewName("foo/index");
        return modelAndView;
    }

spring.profiles.active和spring.config.activate.on-profile区别

spring config profile

--spring.config.name
--spring.config.location
--spring.config.import
--spring.profiles.default
--spring.profiles.active
--spring.profiles.include
--spring.config.activate.on-profile

authenticated()permitAll()

authenticated()是受保护的(也就是需要登录后访问的)
permitAll()是不受保护的(也就是无需登录即可访问的)

spring-cloud 版本跟踪

application-properties

spring-boot-dependency-versions

org.springframework.security.crypto.password.PasswordEncoder

ref https://docs.spring.io/spring-security/site/docs/current/api/org/springframework/security/crypto/password/PasswordEncoder.html

  • AbstractPasswordEncoder
  • Argon2PasswordEncoder
  • BCryptPasswordEncoder
  • DelegatingPasswordEncoder
  • LdapShaPasswordEncoder
  • Md4PasswordEncoder
  • MessageDigestPasswordEncoder
  • NoOpPasswordEncoder
  • Pbkdf2PasswordEncoder
  • SCryptPasswordEncoder
  • StandardPasswordEncoder

org.springframework.session.SessionRepository

  • org.springframework.session.hazelcast.HazelcastIndexedSessionRepository
  • org.springframework.session.jdbc.JdbcIndexedSessionRepository
  • org.springframework.session.MapSessionRepository
  • org.springframework.session.data.mongo.MongoIndexedSessionRepository
  • org.springframework.session.data.redis.RedisIndexedSessionRepository
  • org.springframework.session.data.redis.RedisSessionRepository
  • org.springframework.session.data.gemfire.GemFireOperationsSessionRepository

org.springframework.session.ReactiveSessionRepository

  • org.springframework.session.ReactiveMapSessionRepository
  • org.springframework.session.data.mongo.ReactiveMongoSessionRepository
  • org.springframework.session.data.redis.ReactiveRedisSessionRepository

org.springframework.security.web.context.SecurityContextRepository

  • org.springframework.security.web.context.DelegatingSecurityContextRepository
  • org.springframework.security.web.context.HttpSessionSecurityContextRepository
  • org.springframework.security.web.context.NullSecurityContextRepository
  • org.springframework.security.web.context.RequestAttributeSecurityContextRepository

org.springframework.core.task.TaskExecutor

https://docs.spring.io/spring-framework/docs/current/javadoc-api/org/springframework/core/task/TaskExecutor.html

  • org.springframework.core.task.SyncTaskExecutor
  • org.springframework.core.task.SimpleAsyncTaskExecutor
  • org.springframework.core.task.support.TaskExecutorAdapter
  • org.springframework.scheduling.concurrent.ConcurrentTaskExecutor
  • org.springframework.scheduling.concurrent.ConcurrentTaskScheduler
  • org.springframework.scheduling.concurrent.DefaultManagedTaskExecutor
  • org.springframework.scheduling.concurrent.DefaultManagedTaskScheduler
  • org.springframework.scheduling.quartz.SimpleThreadPoolTaskExecutor
  • org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor
  • org.springframework.scheduling.concurrent.ThreadPoolTaskScheduler

org.springframework.security.web.authentication.rememberme.PersistentTokenRepository

  • org.springframework.security.web.authentication.rememberme.JdbcTokenRepositoryImpl
  • org.springframework.security.web.authentication.rememberme.InMemoryTokenRepositoryImpl

org.springframework.security.config.http.SessionCreationPolicy

  • ALWAYS Always create an HttpSession
  • IF_REQUIRED Spring Security will only create an HttpSession if required
  • NEVER Spring Security will never create an HttpSession, but will use the HttpSession if it already exists
  • STATELESS Spring Security will never create an HttpSession and it will never use it to obtain the SecurityContext

org.springframework.web.servlet.HandlerInterceptor

logback

net.logstash.logback.composite.GlobalCustomFieldsJsonProvider

net.logstash.logback.composite.accessevent.AccessEventPatternJsonProvider
net.logstash.logback.composite.loggingevent.LoggingEventPatternJsonProvider
net.logstash.logback.composite.loggingevent.LogstashMarkersJsonProvider

net.logstash.logback.composite
  AbstractFormattedTimestampJsonProvider
  AbstractNestedJsonProvider
  AbstractSequenceJsonProvider
  AbstractThreadNameJsonProvider
  ContextJsonProvider
  LogstashVersionJsonProvider
  SequenceJsonProvider
  UuidJsonProvider
net.logstash.logback.composite.accessevent
  ContentLengthJsonProvider
  ElapsedTimeJsonProvider
  MethodJsonProvider
  ProtocolJsonProvider
  RemoteHostJsonProvider
  RemoteUserJsonProvider
  RequestedUriJsonProvider
  RequestedUrlJsonProvider
  RequestHeadersJsonProvider
  ResponseHeadersJsonProvider
  StatusCodeJsonProvider
net.logstash.logback.composite.loggingevent
  AbstractThrowableClassNameJsonProvider
  AbstractThrowableMessageJsonProvider
  ArgumentsJsonProvider
  CallerDataJsonProvider
  ContextNameJsonProvider
  KeyValuePairsJsonProvider
  LoggerNameJsonProvider
  LogLevelJsonProvider
  LogLevelValueJsonProvider
  MdcJsonProvider
  MessageJsonProvider
  RawMessageJsonProvider
  RootStackTraceElementJsonProvider
  StackHashJsonProvider
  StackTraceJsonProvider
  TagsJsonProvider

xadd myStream * field1 value1

命令讲解 xadd myStream * field1 value1

这个命令看起来像是使用xadd命令向Redis流数据结构(Stream)中添加数据。下面是对这个命令的解释:

xadd: xadd是Redis的一个命令,用于向Stream数据结构中添加新的条目。
myStream: myStream是指定的Stream名称,表示将要向哪个Stream添加数据。
*: *表示新的条目的ID将由Redis自动生成。Redis会为每个条目生成一个唯一的ID,可以用来标识该条目。
field1: field1是Stream中的字段名称,表示将要添加的数据的字段名称。
value1: value1是要添加到field1字段中的值。
综合起来,这个命令的作用是向名为myStream的Stream中添加一条新的数据,该数据包含一个字段field1,字段值为value1,并由Redis自动生成一个唯一的ID作为条目的ID。

@RequiredArgsConstructor 和 @Qualifier(“beanName”) 组合不生效

vue

npm create vite@latest my-vue-app -- --template vue-ts
cd my-vue-app/

npm install
npm run dev

/api/** 和/api/*的区别是什么?

在 Spring MVC 中,/api/** 和 /api/* 是两种不同的 URL 路径匹配模式,它们之间有一些区别:

/api/**:表示匹配以 /api/ 开头的任何路径,包括子路径。例如,/api/user、/api/user/details、/api/user/profile 等路径都会被匹配到。

/api/*:表示匹配以 /api/ 开头的一级路径,不包括子路径。也就是说,只有直接以 /api/ 后面跟着一个路径时才会被匹配到。例如,/api/user 会被匹配到,但/api/user/details、/api/user/profile 等路径不会被匹配到。

因此,/api/** 匹配更加灵活,可以匹配多级路径,而 /api/* 只能匹配一级路径。根据具体的需求和 URL 结构,您可以选择使用其中一种路径匹配模式来定义请求映射。

matching-strategy

spring:
  mvc:
    pathmatch:
      matching-strategy: ant_path_matcher

server.servlet.context-path和spring.mvc.servlet.path

server.servlet.context-path=/context-path
spring.mvc.servlet.path=/servlet-path

Then the application servlet path will become http://localhost:8080/context-path/servlet-path.

关闭特定的自动配置类

@SpringBootApplication(exclude = org.springframework.boot.autoconfigure.web.servlet.error.ErrorMvcAutoConfiguration.class)

@EnableAutoConfiguration(exclude = org.springframework.boot.autoconfigure.hazelcast.HazelcastAutoConfiguration.class)

spring.autoconfigure.exclude=org.springframework.boot.autoconfigure.security.servlet.SecurityAutoConfiguration

PostConstruct and PreDestroy

import javax.annotation.PostConstruct;
import javax.annotation.PreDestroy;
import org.springframework.beans.factory.DisposableBean;
import org.springframework.beans.factory.InitializingBean;
import org.springframework.beans.factory.config.BeanFactoryPostProcessor;
import org.springframework.beans.factory.config.BeanPostProcessor;
import org.springframework.boot.ApplicationRunner;
import org.springframework.boot.CommandLineRunner;

@EventListener org.springframework.boot.context.event.SpringApplicationEvent
ApplicationContextInitializedEvent
ApplicationEnvironmentPreparedEvent
ApplicationFailedEvent
ApplicationPreparedEvent
ApplicationReadyEvent
ApplicationStartedEvent
ApplicationStartingEvent
ApplicationStartedEvent