参考文档:
https://www.freebuf.com/articles/web/180874.html
https://www.cnblogs.com/pcheng/p/9629621.html
测试RSA网站:http://www.metools.info/code/c81.html
参考文档:
https://www.jianshu.com/p/12b609e40029#1579472924802
https://www.jianshu.com/p/576dbf44b2ae
三部分组成:
字段 | 名称 | 备注 |
---|---|---|
header | 头部 | 1.声明类型:jwt 2.声明算法 3.base64加密 |
payload | 载荷 | 1.标准中注册的声明 iss: jwt签发者 sub: jwt所面向的用户 aud: 接收jwt的一方 exp: jwt的过期时间,这个过期时间必须要大于签发时间 nbf: 定义在什么时间之前,该jwt都是不可用的 iat: jwt的签发时间 jti: jwt的唯一身份标识,主要用来作为一次性token,从而回避重放攻击。 2.公共的声明 3.私有的声明 |
signature | 签证 | base64加密后的header和base64加密后的payload使用. 连接组成的字符串,然后通过header中声明的加密方式进行加盐 secret 组合加密。*** 没试出来** |
测试网站:https://jwt.io/#libraries-io
参考文档:
https://blog.csdn.net/JosephThatwho/article/details/114876345
https://blog.csdn.net/weixin_39603469/article/details/114862527?utm_medium=distribute.pc_relevant.none-task-blog-OPENSEARCH-4.control&dist_request_id=&depth_1-utm_source=distribute.pc_relevant.none-task-blog-OPENSEARCH-4.control
JWK的作用是为JWT(id_token)提供加密密钥,用于加密/解密或签名/验签,是JSON格式的数据。(用来存储公钥PublicKey、私钥PrivateKey、密钥SecretKey)
主要属性:kty(Key类型),use(两个可选值:sig or enc),alg(具体的算法),kid(Key的唯一标识id)
JWK本身未定义一种新的加密算法或变种,只是定义一种JSON格式的数据展示(更符合互联网传输),其底层实现依旧依赖PKI体系的技术,如x509,公钥/私钥体系。在其协议介绍中能更好地体现出来。
测试网站:https://mkjwk.org/
参考文档:https://blog.csdn.net/hukun910903/article/details/79513203
私钥和公钥的验签和加密
参考文档:https://blog.csdn.net/qq_23167527/article/details/80614454
参考文档:
https://blog.csdn.net/taoerchun/article/details/94478080
https://blog.csdn.net/jal517486222/article/details/82663177?utm_medium=distribute.pc_relevant.none-task-blog-BlogCommendFromBaidu-2.nonecase&depth_1-utm_source=distribute.pc_relevant.none-task-blog-BlogCommendFromBaidu-2.nonecase
git fetch --all
git reset --hard origin/master 或者 git reset --hard origin/<branch_name>
git pull
参考文档:
https://blog.csdn.net/nakiri_arisu/article/details/80259531
https://blog.csdn.net/mango_love/article/details/87261529
git reset --hard
git pull origin master
参考文档:https://blog.csdn.net/weixin_43606158/article/details/90728795
git reset --hard 版本号
参考文档:https://blog.csdn.net/chdyiboke/article/details/90200323
//你修改的文件,已经被他人修改 下面pull报错
git pull
git add .
git commit -m 'commit'
git merge master
//手动修改冲突文件
git add .
git commit -m 'merge'
git push
方法一:idea工具设置
参考文档:https://blog.csdn.net/xiaolin_2016/article/details/107014696
个人感觉临时做法,不大好使。
方法二:使用.ignore插件在IDEA中忽略你要提交的文件
参考文档:https://blog.csdn.net/fengchao2016/article/details/72957945/
个人比较喜欢第二种方法
方法三:已add,再撤回
参考文档:https://jingyan.baidu.com/article/0320e2c1b098b75b87507bb4.html
git status
git reset 文件路径
方法四:已在版本管理中,删除某个文件
参考文档:
https://blog.csdn.net/qq_34590097/article/details/56284935
https://blog.csdn.net/weiyoushi4001/article/details/82495364/
某些文件删除需要权限,慎重删除
git rm -r --cached .idea # 文件路径
git commit -m '删除.idea'
git push -u origin master
修改git地址
方法一:idea工具设置
参考文档:https://cloud.tencent.com/developer/article/1515482
方法二:文件夹内修改
参考文档:https://blog.csdn.net/qq_36451496/article/details/103475478
方法三:git 命令
参考文档:https://blog.csdn.net/qq_36451496/article/details/103475478
git remote set-url origin URL // 更换远程仓库地址,URL为新地址。
git push origin --delete dev
参考文档:
https://www.jianshu.com/p/69dcb1b85bbb
https://blog.csdn.net/github_34645245/article/details/81359519
https://bbs.csdn.net/topics/391963414?page=1
https://www.oschina.net/question/1435284_175173
https://www.jianshu.com/p/67249c7b81d4
https://www.jianshu.com/p/d1a5e8f590fb
1.JPAQueryFactory 原生QueryDSL
2.JPAExpressions
3.继承QueryDslPredicateExecutor接口
4.BooleanBuilder
5.@Query 原生sql
6.PageRequest 分页条件-代码里加
7.@SortDefault 分页排序
8.in 批量操作
参考文档:
https://blog.csdn.net/imaginehero/article/details/103744657
https://blog.csdn.net/weixin_39835887/article/details/84921565
https://blog.csdn.net/weihaoshuai2012/article/details/106427453?utm_medium=distribute.pc_relevant.none-task-blog-BlogCommendFromMachineLearnPai2-1.edu_weight&depth_1-utm_source=distribute.pc_relevant.none-task-blog-BlogCommendFromMachineLearnPai2-1.edu_weight
https://blog.csdn.net/weixin_43424932/article/details/104107037?utm_medium=distribute.pc_relevant.none-task-blog-BlogCommendFromMachineLearnPai2-1.edu_weight&depth_1-utm_source=distribute.pc_relevant.none-task-blog-BlogCommendFromMachineLearnPai2-1.edu_weight
https://blog.csdn.net/qq_31289187/article/details/88055780
https://blog.csdn.net/f0rd_/article/details/100514549
https://blog.csdn.net/xp541130126/article/details/81739760
spring:
datasource:
primary:
type: com.zaxxer.hikari.HikariDataSource
driverClassName: oracle.jdbc.OracleDriver
jdbc-url: jdbc:oracle:thin:@localhost:1521:111
username: 111
password: 111
hikari:
minimum-idle: 1
maximum-pool-size: 3
secondary:
type: com.zaxxer.hikari.HikariDataSource
driverClassName: oracle.jdbc.OracleDriver
jdbc-url: jdbc:oracle:thin:@localhost:1521:222
username: 222
password: 222
hikari:
minimum-idle: 1
maximum-pool-size: 3
jpa:
show-sql: true
open-in-view: false
properties:
hibernate:
format_sql: false
first-dialect: org.hibernate.dialect.Oracle10gDialect
first-default_schema: 111
second-dialect: org.hibernate.dialect.Oracle10gDialect
second-default_schema: 222
# hbm2ddl:
# auto: update
data:
web:
pageable:
oneIndexedParameters: true
sizeParameter: size
@Configuration
public class DataSourceConfig {
/***
* 配置主数据源
* @return
*/
@Bean(name = "primaryDataSource")
@Qualifier("primaryDataSource")
@ConfigurationProperties(prefix = "spring.datasource.primary")
public DataSource primaryDataSource() {
return DataSourceBuilder.create().build();
}
/****
* 配置2号数据源
* @return
*/
@Bean(name = "secondaryDataSource")
@Qualifier("secondaryDataSource")
@Primary
@ConfigurationProperties(prefix = "spring.datasource.secondary")
public DataSource secondaryDataSource() {
return DataSourceBuilder.create().build();
}
}
@Configuration
@EnableTransactionManagement
@EnableJpaRepositories(
entityManagerFactoryRef = "entityManagerFactoryPrimary",//配置连接工厂 entityManagerFactory
transactionManagerRef = "transactionManagerPrimary", //配置 事物管理器 transactionManager
basePackages = {
"xxx.repositories","xxx.repositories"}//设置持久层所在位置
)
public class FirstConfig {
@Autowired
@Qualifier("primaryDataSource")
private DataSource primaryDataSource;// 自动注入配置好的数据源
@Value("${spring.jpa.properties.hibernate.first-dialect}")
private String primaryDialect;// 获取对应的数据库方言
@Value("${spring.jpa.properties.hibernate.first-default_schema}")
private String primaryDefaultSchema;
@Primary
@Bean(name = "entityManagerPrimary")
public EntityManager entityManager(EntityManagerFactoryBuilder builder) {
return entityManagerFactoryPrimary(builder).getObject().createEntityManager();
}
/**
* @param builder
* @return
*/
@Bean(name = "entityManagerFactoryPrimary")
@Primary
public LocalContainerEntityManagerFactoryBean entityManagerFactoryPrimary(EntityManagerFactoryBuilder builder) {
return builder
//设置数据源
.dataSource(primaryDataSource)
//设置数据源属性
.properties(getVendorProperties())
//设置实体类所在位置.扫描所有带有 @Entity 注解的类
.packages("xxx.models","xxx.models")
// Spring会将EntityManagerFactory注入到Repository之中.有了 EntityManagerFactory之后,
// Repository就能用它来创建 EntityManager 了,然后 EntityManager 就可以针对数据库执行操作
.persistenceUnit("primaryPersistenceUnit")
.build();
}
private Map getVendorProperties() {
Map<String, Object> properties = new HashMap<>();
properties.put("hibernate.dialect",
primaryDialect);
properties.put("hibernate.default_schema",
primaryDefaultSchema);
return properties;
}
/**
* 配置事物管理器
*
* @param builder
* @return
*/
@Bean(name = "transactionManagerPrimary")
@Primary
PlatformTransactionManager transactionManagerPrimary(EntityManagerFactoryBuilder builder) {
return new JpaTransactionManager(entityManagerFactoryPrimary(builder).getObject());
}
}
@Configuration
@EnableTransactionManagement
@EnableJpaRepositories(
entityManagerFactoryRef = "entityManagerFactorySecondary",//配置连接工厂 entityManagerFactory
transactionManagerRef = "transactionManagerSecondary", //配置 事物管理器 transactionManager
basePackages = {
"xxx.repositories",
"xxx.repositories",
"xxx.repositories"}//设置持久层所在位置
)
public class SecondConfig {
@Autowired
@Qualifier("secondaryDataSource")
private DataSource secondaryDataSource;// 自动注入配置好的数据源
@Value("${spring.jpa.properties.hibernate.second-dialect}")
private String secondDialect;// 获取对应的数据库方言
@Value("${spring.jpa.properties.hibernate.second-default_schema}")
private String secondDefaultSchema;
@Bean(name = "entityManagerSecondary")
public EntityManager entityManager(EntityManagerFactoryBuilder builder) {
return entityManagerFactorySecondary(builder).getObject().createEntityManager();
}
/**
* @param builder
* @return
*/
@Bean(name = "entityManagerFactorySecondary")
public LocalContainerEntityManagerFactoryBean entityManagerFactorySecondary(EntityManagerFactoryBuilder builder) {
return builder
//设置数据源
.dataSource(secondaryDataSource)
//设置数据源属性
.properties(getVendorProperties())
//设置实体类所在位置.扫描所有带有 @Entity 注解的类
.packages("xxx.models", "xxx.models", "xxx.models")
// Spring会将EntityManagerFactory注入到Repository之中.有了 EntityManagerFactory之后,
// Repository就能用它来创建 EntityManager 了,然后 EntityManager 就可以针对数据库执行操作
.persistenceUnit("secondaryPersistenceUnit")
.build();
}
private Map getVendorProperties() {
Map<String, Object> properties = new HashMap<>();
properties.put("hibernate.dialect",
secondDialect);
properties.put("hibernate.default_schema",
secondDefaultSchema);
return properties;
}
/**
* 配置事物管理器
*
* @param builder
* @return
*/
@Bean(name = "transactionManagerSecondary")
PlatformTransactionManager transactionManagerSecondary(EntityManagerFactoryBuilder builder) {
return new JpaTransactionManager(entityManagerFactorySecondary(builder).getObject());
}
}
参考文档:https://blog.csdn.net/qq_35387940/article/details/102563845
spring:
datasource:
# driver-class-name: com.mysql.cj.jdbc.Driver
driver-class-name: net.sf.log4jdbc.sql.jdbcapi.DriverSpy
# url: jdbc:mysql://localhost:3306/testdemo?useSSL=false&useUnicode=true&characterEncoding=UTF-8&serverTimezone=GMT%2B8&zeroDateTimeBehavior=convertToNull
url: jdbc:log4jdbc:mysql://localhost:3306/testdemo?useSSL=false&useUnicode=true&characterEncoding=UTF-8&serverTimezone=GMT%2B8&zeroDateTimeBehavior=convertToNull
hikari: # springboot 2.0 整合了hikari ,据说这是目前性能最好的java数据库连接池
username: root
password: root
minimum-idle: 5 # 最小空闲连接数量
idle-timeout: 180000 # 空闲连接存活最大时间,默认600000(10分钟)
maximum-pool-size: 10 # 连接池最大连接数,默认是10
auto-commit: true # 此属性控制从池返回的连接的默认自动提交行为,默认值:true
pool-name: MyHikariCP # 连接池名称
max-lifetime: 1800000 # 此属性控制池中连接的最长生命周期,值0表示无限生命周期,默认1800000即30分钟
connection-timeout: 30000 # 数据库连接超时时间,默认30秒,即30000
# connection-test-query: SELECT 1 #连接池每分配一条连接前执行的查询语句(如:SELECT 1),以验证该连接是否是有效的。如果你的驱动程序支持 JDBC4,HikariCP 强烈建议我们不要设置此属性
jpa:
hibernate:
ddl-auto: update # 第一次建表create 后面用update,要不然每次重启都会新建表
# show-sql: true #打印执行的sql语句
database-platform: org.hibernate.dialect.MySQL5InnoDBDialect #设置数据库方言 记住必须要使用 MySQL5InnoDBDialect 指定数据库类型对应InnoDB ;如果使用MySQLDialect 则对应的是MyISAM
# If you use SLF4J. First, you need to tell log4jdbc-log4j2 that you want to use the SLF4J logger
log4jdbc.spylogdelegator.name=net.sf.log4jdbc.log.slf4j.Slf4jSpyLogDelegator
<configuration scan="true">
<property name="LOG_PATH" value="./logs"/>
<property name="APPDIR" value="graceLogs"/>
<appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
<encoder>
<pattern>1-%d{yyyy-MM-dd HH:mm:ss} [%thread] %-5level %logger - %msg%npattern>
<charset>GBKcharset>
encoder>
appender>
<appender name="FILEERROR" class="ch.qos.logback.core.rolling.RollingFileAppender">
<file>${LOG_PATH}/${APPDIR}/log_error.logfile>
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
<fileNamePattern>${LOG_PATH}/${APPDIR}/error/log-error-%d{yyyy-MM-dd}.%i.logfileNamePattern>
<timeBasedFileNamingAndTriggeringPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP">
<maxFileSize>500MBmaxFileSize>
timeBasedFileNamingAndTriggeringPolicy>
rollingPolicy>
<append>trueappend>
<encoder class="ch.qos.logback.classic.encoder.PatternLayoutEncoder">
<pattern>%d{yyyy-MM-dd HH:mm:ss.SSS} %-5level %logger Line:%-3L - %msg%npattern>
<charset>utf-8charset>
encoder>
<filter class="ch.qos.logback.classic.filter.LevelFilter">
<level>errorlevel>
<onMatch>ACCEPTonMatch>
<onMismatch>DENYonMismatch>
filter>
appender>
<appender name="FILEWARN" class="ch.qos.logback.core.rolling.RollingFileAppender">
<file>${LOG_PATH}/${APPDIR}/log_warn.logfile>
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
<fileNamePattern>${LOG_PATH}/${APPDIR}/warn/log-warn-%d{yyyy-MM-dd}.%i.logfileNamePattern>
<timeBasedFileNamingAndTriggeringPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP">
<maxFileSize>2MBmaxFileSize>
timeBasedFileNamingAndTriggeringPolicy>
rollingPolicy>
<append>trueappend>
<encoder class="ch.qos.logback.classic.encoder.PatternLayoutEncoder">
<pattern>%d{yyyy-MM-dd HH:mm:ss.SSS} %-5level %logger Line:%-3L - %msg%npattern>
<charset>utf-8charset> encoder>
<filter class="ch.qos.logback.classic.filter.LevelFilter">
<level>warnlevel>
<onMatch>ACCEPTonMatch>
<onMismatch>DENYonMismatch>
filter>
appender>
<appender name="FILEINFO" class="ch.qos.logback.core.rolling.RollingFileAppender">
<file>${LOG_PATH}/${APPDIR}/log_info.logfile>
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
<fileNamePattern>${LOG_PATH}/${APPDIR}/info/log-info-%d{yyyy-MM-dd}.%i.logfileNamePattern>
<timeBasedFileNamingAndTriggeringPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP">
<maxFileSize>2MBmaxFileSize>
timeBasedFileNamingAndTriggeringPolicy>
rollingPolicy>
<append>trueappend>
<encoder class="ch.qos.logback.classic.encoder.PatternLayoutEncoder">
<pattern>%d{yyyy-MM-dd HH:mm:ss.SSS} %-5level %logger Line:%-3L - %msg%npattern>
<charset>utf-8charset>
encoder>
<filter class="ch.qos.logback.classic.filter.LevelFilter">
<level>infolevel>
<onMatch>ACCEPTonMatch>
<onMismatch>DENYonMismatch>
filter>
appender>
<appender name="CONSOLE" class="ch.qos.logback.core.ConsoleAppender">
<encoder>
<pattern>%d{yyyy-MM-dd HH:mm:ss.SSS} %-5level %logger Line:%-3L - %msg%npattern>
encoder>
appender>
<logger name="jdbc.connection" level="OFF"/>
<logger name="jdbc.resultset" level="OFF"/>
<logger name="jdbc.resultsettable" level="OFF"/>
<logger name="jdbc.audit" level="OFF"/>
<logger name="jdbc.sqltiming" level="INFO"/>
<logger name="jdbc.sqlonly" level="OFF"/>
<root level="INFO">
<appender-ref ref="CONSOLE"/>
<appender-ref ref="FILEINFO"/>
<appender-ref ref="FILEWARN"/>
<appender-ref ref="FILEERROR"/>
root>
configuration>
参考文档:
https://www.pianshen.com/article/721751997/
https://www.jianshu.com/p/9fca4f3cd2d1
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;
import javax.websocket.*;
import javax.websocket.server.PathParam;
import javax.websocket.server.ServerEndpoint;
import java.io.IOException;
import java.util.concurrent.CopyOnWriteArraySet;
/**
* web socket 工具类
*
* @author alvinqiu
* @data 2018/10/24
*/
@Slf4j
@Component
@ServerEndpoint(value = "/ws/{type}")
public class WebSocketServer {
/**
* concurrent包的线程安全Set,用来存放每个客户端对应的Session对象
*/
private static CopyOnWriteArraySet<Session> SessionSet = new CopyOnWriteArraySet<Session>();
@OnOpen
public void onOpen(@PathParam("type") String type, Session session) {
SessionSet.add(session);
log.info("WebSocket有连接加入, 请求的数据类型为: " + type);
try {
sendMessage("Hello WebSocket " + type);
} catch (IOException e) {
e.printStackTrace();
}
}
@OnClose
public void onClose(Session session) {
SessionSet.remove(session);
log.info("WebSocket有连接关闭");
}
@OnError
public void onError(Throwable error) {
log.info("WebSocket发生错误, 原因: " + error.getMessage());
}
@OnMessage
public void onMessage(String message) {
log.info("收到来自WebSocket客户端的消息: " + message);
}
/**
* 发送消息给客户端
*
* @param message
* @throws IOException
*/
public void sendMessage(String message) throws IOException {
for (Session session : SessionSet) {
if (session.isOpen()) {
session.getBasicRemote().sendText(message);
}
}
}
}
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.socket.server.standard.ServerEndpointExporter;
/**
* web socket 配置类
*
* @author alvinqiu
* @data 2018/10/24
*/
@Configuration
public class WebSocketConfig {
@ConditionalOnClass({
Servlet.class, Tomcat.class })
@Bean
public ServerEndpointExporter serverEndpointExporter() {
return new ServerEndpointExporter();
}
}
前端需要安装websocket
以vue为例
参考文档:https://blog.csdn.net/ZyLL_123/article/details/104097733?utm_medium=distribute.pc_relevant_t0.none-task-blog-BlogCommendFromMachineLearnPai2-1.edu_weight&depth_1-utm_source=distribute.pc_relevant_t0.none-task-blog-BlogCommendFromMachineLearnPai2-1.edu_weight
测试地址:http://www.websocket-test.com/
参考文档:https://www.jianshu.com/p/5f06e18ed520
参考文档:https://blog.csdn.net/zsj777/article/details/93602954?depth_1-utm_source=distribute.pc_relevant.none-task&utm_source=distribute.pc_relevant.none-task
1.生成注解接口
@Target({
ElementType.PARAMETER})//Annotation所修饰的对象范围:方法参数
@Retention(RetentionPolicy.RUNTIME)//Annotation被保留时间:运行时保留(有效)
@Documented//标记注解:java工具文档化
public @interface CurrentUser {
}
2.生成用户信息类
3.注解解析实现
@Component
public class UserArgumentResolver implements HandlerMethodArgumentResolver {
private final Logger logger = LoggerFactory.getLogger(UserArgumentResolver.class);
/**
* 过滤出符合条件的参数,这里指的是加了 CurrentUser 注解的参数
*
* @param parameter
* @return
*/
@Override
public boolean supportsParameter(MethodParameter parameter) {
AnnotatedElement annotatedElement = parameter.getAnnotatedElement();
Annotation[] annotations = annotatedElement.getAnnotations();
logger.info(annotations.toString());
return parameter.hasParameterAnnotation(CurrentUser.class);
}
@Override
public UserInfoBean resolveArgument(MethodParameter parameter, ModelAndViewContainer mavContainer, NativeWebRequest
webRequest, WebDataBinderFactory binderFactory) {
HttpServletRequest servletRequest = webRequest.getNativeRequest(HttpServletRequest.class);
//获取token
String token = SpringContextUtil.getHeadInfo(servletRequest, ConstantUtil.Token);
if (StringUtils.isBlank(token)) {
//todo 用户信息获取
//UserInfoBean userInfoBo = new UserInfoBean();
} else {
//根据token获取用户信息
return JwtTokenUtil.parsingUserInformation(token);
}
return null;
}
}
参考文档:https://www.jianshu.com/p/09c6b05b670a
注解
@Target(ElementType.METHOD) // 作用到方法上
@Retention(RetentionPolicy.RUNTIME) // 运行时有效
/**
* @功能描述 防止重复提交标记注解
* @author www.gaozz.club
* @date 2018-08-26
*/
public @interface NoRepeatSubmit {
}
aop解析
@Aspect
@Component
/**
* @功能描述 aop解析注解
* @author www.gaozz.club
* @date 2018-08-26
*/
public class NoRepeatSubmitAop {
private Log logger = LogFactory.getLog(getClass());
@Autowired
private Cache<String, Integer> cache;
@Around("execution(* com.example..*Controller.*(..)) && @annotation(nrs)")
public Object arround(ProceedingJoinPoint pjp, NoRepeatSubmit nrs) {
try {
ServletRequestAttributes attributes = (ServletRequestAttributes) RequestContextHolder.getRequestAttributes();
String sessionId = RequestContextHolder.getRequestAttributes().getSessionId();
HttpServletRequest request = attributes.getRequest();
String key = sessionId + "-" + request.getServletPath();
if (cache.getIfPresent(key) == null) {
// 如果缓存中有这个url视为重复提交
Object o = pjp.proceed();
cache.put(key, 0);
return o;
} else {
logger.error("重复提交");
return null;
}
} catch (Throwable e) {
e.printStackTrace();
logger.error("验证重复提交时出现未知异常!");
return "{\"code\":-889,\"message\":\"验证重复提交时出现未知异常!\"}";
}
}
}
缓存类
/**
* @功能描述 内存缓存
* @author www.gaozz.club
* @date 2018-08-26
*/
@Configuration
public class UrlCache {
@Bean
public Cache<String, Integer> getCache() {
return CacheBuilder.newBuilder().expireAfterWrite(2L, TimeUnit.SECONDS).build();// 缓存有效期为2秒
}
}
测试类
@RestController
public class TestController {
@RequestMapping("/test")
@NoRepeatSubmit
public String test() {
return ("程序逻辑返回");
}
}
参考文档:
https://blog.csdn.net/yang_zeng/article/details/99549119
https://www.cnblogs.com/ChromeT/p/10932202.html
https://www.cnblogs.com/wlwl/p/10056067.html
https://www.jianshu.com/p/71d46f252f3a
参考文档:
https://blog.csdn.net/weixin_30925411/article/details/99961781
https://blog.csdn.net/badfraud/article/details/90601271
https://www.jianshu.com/p/e4c035833810
https://cloud.tencent.com/developer/article/1449255
@Configuration
@EnableAsync
public class AsyncEventConfiguration implements AsyncConfigurer {
@Override
public Executor getAsyncExecutor() {
return Executors.newCachedThreadPool();
}
}
@Component
public class MyEvent extends ApplicationEvent {
public MyEvent(ApplicationContext source) {
super(source);
System.out.println("MyEvent 构造器执行");
}
public void echo() {
System.out.println("模拟业务逻辑执行");
}
}
@Component
public class MyListenerA implements ApplicationListener<MyEvent> {
@Override
public void onApplicationEvent(MyEvent myEvent) {
System.out.println("MyListenerA");
myEvent.echo();
}
}
@Component
public class MyListenerB {
@EventListener
public void onApplicationEvent(MyEvent myEvent) {
System.out.println("MyListenerB");
myEvent.echo();
}
}
@Component
public class MyPublisher implements ApplicationContextAware {
private ApplicationContext applicationContext;
@Override
public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
this.applicationContext = applicationContext;
}
/**
* 发布事件
* 监听该事件的监听者都可以获取消息
*
* @param myEvent
*/
public void publisherEvent(MyEvent myEvent) {
System.out.println("---开始发布 myEvent 事件---");
applicationContext.publishEvent(myEvent);
}
}
@RunWith(SpringRunner.class)
@SpringBootTest
public class DesignPatternsApplicationTests {
@Autowired
private MyPublisher myPublisher;
@Autowired
private MyEvent myEvent;
@Test
public void contextLoads() {
myPublisher.publisherEvent(myEvent);
}
}
参考文档:
https://www.cnblogs.com/porotin/p/7825656.html
https://blog.csdn.net/weixin_38003389/article/details/88052943
和观察者模式息息相关
参考文档:
https://blog.csdn.net/weixin_42073629/article/details/106303089?utm_medium=distribute.pc_relevant.none-task-blog-baidujs_title-0&spm=1001.2101.3001.4242
https://blog.csdn.net/ignorewho/article/details/80702827
参考文档:
https://www.jianshu.com/p/2d4b89c7a3f1
https://blog.csdn.net/weixin_39800144/article/details/79046237
https://blog.csdn.net/weixin_38399962/article/details/82146480
https://zhuanlan.zhihu.com/p/45207411
*例子和线程池合并在一起
*如果异步任务有返回值,需要批量读取,不能单独读取
异步和线程池可以一起混搭
参考文档:
https://www.cnblogs.com/expiator/p/11128357.html
https://blog.csdn.net/boling_cavalry/article/details/79120268
创建线程池
/**
* 异步处理1:线程池,创建新线程处理
* @return
*/
@RequestMapping(value = "test3",method = RequestMethod.GET)
public String test3(){
ExecutorService service = Executors.newFixedThreadPool(5);
RunnableTask1 task1 = new RunnableTask1();
service.asyncServiceExecutor(task1);
logger.info("=========》当前线程名:"+Thread.currentThread().getName());
return "异步,正在解析......";
}
线程池的配置
@Bean
public Executor asyncServiceExecutor() {
logger.info("start asyncServiceExecutor");
//使用VisiableThreadPoolTaskExecutor
ThreadPoolTaskExecutor executor = new VisiableThreadPoolTaskExecutor();
//配置核心线程数
executor.setCorePoolSize(5);
//配置最大线程数
executor.setMaxPoolSize(5);
//配置队列大小
executor.setQueueCapacity(99999);
//配置线程池中的线程的名称前缀
executor.setThreadNamePrefix("async-service-");
// rejection-policy:当pool已经达到max size的时候,如何处理新任务
// CALLER_RUNS:不在新线程中执行任务,而是有调用者所在的线程来执行
executor.setRejectedExecutionHandler(new ThreadPoolExecutor.CallerRunsPolicy());
//执行初始化
executor.initialize();
return executor;
}
方式一
public class RunnableTask1 implements Runnable{
private final Logger logger = LoggerFactory.getLogger(getClass());
@Override
public void run(){
Building building = new Building();
synchronized (building){
try {
for (int i = 1;i <= 100;i++){
System.out.println(Thread.currentThread().getName()+"----------异步:>"+i);
building.wait(200);
}
}catch (Exception ex){
ex.printStackTrace();
}
}
}
}
方式二
@RestController
@RequestMapping("tmall")
@EnableAsync
public class LoginController {
private final org.slf4j.Logger logger = LoggerFactory.getLogger(getClass());
@Autowired
private LoginService loginService;
/**
* 异步处理2:使用springBoot自带async注解
*/
@RequestMapping(value = "test1",method = RequestMethod.GET)
public String test1(){
loginService.getTest1();
logger.info("============>"+Thread.currentThread().getName());
return "异步,正在解析......";
}
测试
@RestController
@RequestMapping("tmall")
@EnableAsync
public class LoginController {
private final org.slf4j.Logger logger = LoggerFactory.getLogger(getClass());
@Autowired
private LoginService loginService;
/**
* 异步处理2:使用springBoot自带async注解
*/
@RequestMapping(value = "test1",method = RequestMethod.GET)
public String test1(){
loginService.getTest1();
logger.info("============>"+Thread.currentThread().getName());
return "异步,正在解析......";
}
=== service =====
/**异步方法
* 有@Async注解的方法,默认就是异步执行的,会在默认的线程池中执行,但是此方法不能在本类调用;启动类需添加直接开启异步执行@EnableAsync。
* */
@Async
@Override
public String getTest1(){
Building building = new Building();
synchronized (building){
try {
for (int i = 1;i <= 100;i++){
logger.info(Thread.currentThread().getName()+"----------异步:>"+i);
building.wait(200);
}
return "执行异步任务完毕";
}catch (Exception ex){
ex.printStackTrace();
}
}
return Thread.currentThread().getName()+"执行完毕";
}
参考文档:https://www.jianshu.com/p/d258b26ef889
根据自己springboot版本来判断,1.0.4之后是这样写的
@Bean
public static PropertySourcesPlaceholderConfigurer properties() {
PropertySourcesPlaceholderConfigurer configurer = new PropertySourcesPlaceholderConfigurer();
YamlPropertiesFactoryBean yaml = new YamlPropertiesFactoryBean();
// yaml.setResources(new ClassPathResource("myconfig.yml"));
yaml.setResources(new FileSystemResource("/data/config/myconfig.yml"));
configurer.setProperties(yaml.getObject());
return configurer;
}
后面可以通过@Value注入属性值
参考文档:https://blog.csdn.net/thc1987/article/details/78789426
参考文档:
https://blog.csdn.net/qq_38974634/article/details/80650810
https://www.cnblogs.com/JiangLai/p/9999811.html
https://www.jianshu.com/p/8905f4a6c30a
参考文档:https://blog.csdn.net/qq_40990854/article/details/81029027
参考文档:https://blog.csdn.net/fukaiit/article/details/92853086
@Component
public class CodeCache {
public static Map<String, String> codeMap = new HashMap<String, String>();
@Autowired
private ICodeService codeService;
@PostConstruct
public void init(){
System.out.println("系统启动中。。。加载codeMap");
List<Code> codeList = codeService.selectAll();
for (Code code : codeList) {
codeMap.put(code.getKey(), code.getValue());
}
}
@PreDestroy
public void destroy(){
System.out.println("系统运行结束");
}
}
@PostConstruct在spring容器初始化的时候执行该方法,执行顺序在依赖注入完之后调用。
参考文档:https://www.jianshu.com/p/98cf7d8b9ec3
参考文档:
https://blog.csdn.net/likekobe2012/article/details/82853622
https://mp.weixin.qq.com/s?__biz=MzIwNTk5NjEzNw==&mid=2247489074&idx=1&sn=d11c1029dd85615f3c6988e3a9f77b99&chksm=97293f34a05eb622892ddf56d1942196446b815aabb0d4f49471c82bbdfbde7913b4b3bfc267&mpshare=1&scene=23&srcid=1223QDDslyY9sBSeytpvQgBq&sharer_sharetime=1577067601852&sharer_shareid=59f1834ca74f70afd02f059c5f4c9e34#rd
参考文档:
https://blog.csdn.net/ieflex/article/details/90644976
https://www.cnblogs.com/xuwujing/p/10933082.html
https://blog.csdn.net/liqingwei168/article/details/88034777
https://segmentfault.com/a/1190000019360868?utm_source=tag-newest
https://blog.csdn.net/sun_t89/article/details/52057014
对@RestControllerAdvice 的了解
参考文档:https://www.jianshu.com/p/47aeeba6414c
public class Result<T> {
public boolean result;
public int code;
public String message;
public T data;
public Result(boolean result,int code,String message){
this.result = result;
this.code = code;
this.message = message;
}
public Result(boolean result,int code,T data){
this.result = result;
this.code = code;
this.data = data;
}
public Result(boolean result,int code,String message,T data){
this.result = result;
this.code = code;
this.message = message;
this.data = data;
}
}
public enum ResultCode {
SUCCESS(200),//成功
FAIL(400),//失败
UNAUTHORIZED(401),//未认证(签名错误) 未登录
NOT_FOUND(404),//接口不存在
INTERNAL_SERVER_ERROR(500);//服务器内部错误
private final int code;
ResultCode(int code) {
this.code = code;
}
public int code() {
return code;
}
}
@Slf4j
@RestControllerAdvice
public class ExceptionAdvice {
@ResponseStatus(HttpStatus.OK)
public Result success(){
return new Result(true, ResultCode.SUCCESS, null);
}
@ResponseStatus(HttpStatus.OK)
public Result success(T data) {
return new Result(true, ResultCode.SUCCESS, data);
}
@ExceptionHandler(Exception.class)
public Result fail(HttpServletResponse resp, Exception e) {
log.error(e.getMessage());
return new Result(false,ResultCode.INTERNAL_SERVER_ERROR, e.getMessage());
}
}
@GetMapping("/doTestObject")
public CallResultMsg testObjectReturn(){
Map<String, Integer> map = new HashMap();
map.put("qingfen", 16);
map.put("lantian", 17);
map.put("baiyun", 18);
return new Result<Map>().success(map);
}
参考文档:
https://blog.csdn.net/u011138533/article/details/87919895
https://blog.csdn.net/shalousun/article/details/80960835?utm_source=blogxgwz5
https://www.bbsmax.com/A/n2d9X2q65D/
/**
* 拦截入参属性错误
*
* @param e 错误
* @return 全局异常信息
*/
@ResponseBody
@ExceptionHandler(MethodArgumentNotValidException.class)
@ResponseStatus(HttpStatus.BAD_REQUEST)
public GlobalResultData methodArgumentNotValidException(MethodArgumentNotValidException e) {
BindingResult bindResult = e.getBindingResult();
GlobalResultData globalErrorData = new GlobalResultData(ResultEnum.FAIL.getDescribe(), ErrorCodeEnum.PARAM_EMPTY.getCode(), "");
String message = "";
for (FieldError fieldError : bindResult.getFieldErrors()) {
message = message.concat(fieldError.getField().concat(":").concat(fieldError.getDefaultMessage()).concat(";"));
}
globalErrorData.setMessage(message);
log.error(bindResult.getObjectName(), globalErrorData.getMessage());
return globalErrorData;
}
参考文档:https://segmentfault.com/q/1010000014749303?utm_source=tag-newest
@Configuration
public class ValidationConfig {
@Bean
public Validator getValidator() {
Validator validator = Validation.byDefaultProvider().
configure().
messageInterpolator(new ResourceBundleMessageInterpolator(new PlatformResourceBundleLocator("i18n/validation/message"))).
buildValidatorFactory().getValidator();
return validator;
}
}
参考文档:
https://blog.csdn.net/duangecho/article/details/80383720
https://blog.csdn.net/cm15835106905/article/details/108849074
https://blog.csdn.net/u013810234/article/details/81136416
添加yml
spring:
servlet:
multipart:
enabled: true
max-file-size: 10MB
max-request-size: 1000MB
server:
tomcat:
max-http-post-size: -1
参考文档:https://www.cnblogs.com/mmzs/p/10161936.html
//@Component注解用于对那些比较中立的类进行注释;
//相对与在持久层、业务层和控制层分别采用 @Repository、@Service 和 @Controller 对分层中的类进行注释
@Component
@EnableScheduling // 1.开启定时任务
@EnableAsync // 2.开启多线程
public class MultithreadScheduleTask {
@Async
@Scheduled(fixedDelay = 1000) //间隔1秒
public void first() throws InterruptedException {
System.out.println("第一个定时任务开始 : " + LocalDateTime.now().toLocalTime() + "\r\n线程 : " + Thread.currentThread().getName());
System.out.println();
Thread.sleep(1000 * 10);
}
@Async
@Scheduled(fixedDelay = 2000)
public void second() {
System.out.println("第二个定时任务开始 : " + LocalDateTime.now().toLocalTime() + "\r\n线程 : " + Thread.currentThread().getName());
System.out.println();
}
}
参考文档:
https://blog.csdn.net/a745233700/article/details/89307518
https://blog.csdn.net/soonfly/article/details/68507615
官方推荐方式 构造器注入
参考文档:https://www.zhihu.com/question/52220502
参考文档:
https://blog.csdn.net/ONROAD0612/article/details/82258193?depth_1-utm_source=distribute.pc_relevant.none-task-blog-BlogCommendFromBaidu-2&utm_source=distribute.pc_relevant.none-task-blog-BlogCommendFromBaidu-2
https://blog.csdn.net/a1032818891/article/details/81172478?depth_1-utm_source=distribute.pc_relevant.none-task-blog-BlogCommendFromBaidu-1&utm_source=distribute.pc_relevant.none-task-blog-BlogCommendFromBaidu-1
https://www.jianshu.com/p/3ba3016cb766
https://www.jianshu.com/p/fd86b5b74301
https://www.cnblogs.com/angusbao/p/7727649.html
@Bean
public RestTemplate restTemplate() throws KeyStoreException, NoSuchAlgorithmException, KeyManagementException {
TrustStrategy acceptingTrustStrategy = (X509Certificate[] chain, String authType) -> true;
SSLContext sslContext = org.apache.http.ssl.SSLContexts.custom()
.loadTrustMaterial(null, acceptingTrustStrategy)
.build();
SSLConnectionSocketFactory csf = new SSLConnectionSocketFactory(sslContext);
CloseableHttpClient httpClient = HttpClients.custom()
.setSSLSocketFactory(csf)
.build();
HttpComponentsClientHttpRequestFactory requestFactory =
new HttpComponentsClientHttpRequestFactory();
requestFactory.setHttpClient(httpClient);
RestTemplate restTemplate = new RestTemplate(requestFactory);
restTemplate.getMessageConverters().add(new WxMappingJackson2HttpMessageConverter());
return restTemplate;
}
private static class WxMappingJackson2HttpMessageConverter extends MappingJackson2HttpMessageConverter {
private WxMappingJackson2HttpMessageConverter() {
List<MediaType> mediaTypes = new ArrayList<>();
mediaTypes.add(MediaType.TEXT_PLAIN);
setSupportedMediaTypes(mediaTypes);
}
}
@Test
public void testHttps(){
String url = "https://free-api.heweather.com/v5/forecast?city=CN101080101&key=5c043b56de9f4371b0c7f8bee8f5b75e";
String resp = restTemplate.getForObject(url, String.class);
System.out.println(resp);
}
参考文档:
https://blog.csdn.net/Z__Sheng/article/details/89489053?utm_medium=distribute.pc_relevant.none-task-blog-BlogCommendFromMachineLearnPai2-1.edu_weight&depth_1-utm_source=distribute.pc_relevant.none-task-blog-BlogCommendFromMachineLearnPai2-1.edu_weight
https://www.hollischuang.com/archives/898
https://blog.csdn.net/qq_20597727/article/details/84900994
原子性(Atomicity):事务作为一个整体被执行,包含在其中的对数据库的操作要么全部被执行,要么都不执行。
一致性(Consistency):事务应确保数据库的状态从一个一致状态转变为另一个一致状态。一致状态的含义是数据库中的数据应满足完整性约束。
隔离性(Isolation):多个事务并发执行时,一个事务的执行不应影响其他事务的执行。
持久性(Durability):一个事务一旦提交,他对数据库的修改应该永久保存在数据库中。
参考文档:https://www.zhihu.com/question/31346392
赞同这个观点:应用系统从一个正确的状态到另一个正确的状态.而ACID就是说事务能够通过AID来保证这个C的过程.C是目的,AID都是手段.
ACID里的AID都是数据库的特征,也就是依赖数据库的具体实现.而唯独这个C,实际上它依赖于应用层,也就是依赖于开发者.这里的一致性是指系统从一个正确的状态,迁移到另一个正确的状态.什么叫正确的状态呢?就是当前的状态满足预定的约束就叫做正确的状态.而事务具备ACID里C的特性是说通过事务的AID来保证我们的一致性.
参考文档:https://cloud.tencent.com/developer/article/1485923
参考文档:https://potoyang.gitbook.io/spring-in-action-v5/di-9-zhang-ji-cheng-spring/9.1-sheng-ming-jian-dan-de-ji-cheng-liu
参考文档:
https://blog.csdn.net/MAILLIBIN/article/details/86584610
https://blog.csdn.net/ysdsxry/article/details/102289258?utm_medium=distribute.pc_relevant.none-task-blog-BlogCommendFromMachineLearnPai2-1.nonecase&depth_1-utm_source=distribute.pc_relevant.none-task-blog-BlogCommendFromMachineLearnPai2-1.nonecase
参考文档:https://www.cnblogs.com/aixinge/p/9145943.html
参考文档:https://cloud.tencent.com/developer/article/1419097
参考文档:https://www.cnblogs.com/mmzs/p/12735212.html#_label3_0
https://blog.csdn.net/alinekang/article/details/79314815
参考文档:
https://blog.csdn.net/qq_41402200/article/details/94333830
https://www.bilibili.com/video/av75536942
https://blog.csdn.net/qq_36752632/article/details/79656716
参考文档:https://blog.csdn.net/huangbaokang/article/details/80059300
参考文档:https://www.cnblogs.com/yuanchaoyong/p/6375871.html
参考文档:https://blog.csdn.net/qq_37774171/article/details/85495018
参考文档:
https://blog.csdn.net/zmx729618/article/details/54018629
https://blog.csdn.net/qq_30553235/article/details/78809872
select count(*) from v$process ; --当前的数据库连接数
select value from v$parameter where name ='processes'; --数据库允许的最大连接数
alter system set processes = 300 scope = spfile; --修改最大连接数:
shutdown immediate; --关闭数据库
startup; --重启数据库
select osuser, a.username, cpu_time/executions/1000000||'s', b.sql_text, machine from v$session a, v$sqlarea b where a.sql_address =b.address order by cpu_time/executions desc; --查看当前有哪些用户正在使用数据
select count(*) from v$session --当前的session连接数
select count(*) from v$session where status='ACTIVE'; --并发连接数
参考文档:
https://zhidao.baidu.com/question/1988708581982998827.html
https://www.bkw.cn/tjs/ask/4650133.html
with t as
(select number rn from master..spt_values where type='P' and number<=23)
select t.rn 小时,SUM(isnull(cnt,0)) 数量 from t left join test on t.rn=cast(substring(CONVERT(varchar,begin_date,120),12,2)
as int) group by t.rn
参考文档:https://blog.csdn.net/fghsfeyhdf/article/details/79807690
exp system/123456@213.234.12.32/mydb file=D:\example.dmp full=y
imp system/123456@213.234.12.32/mydb file=D:\example.dmp full=y ignore=y
参考文档:
https://www.cnblogs.com/fyter/p/stored_procedure_gen_much_data.html
https://www.jianshu.com/p/4f728a575cce
CREATE PROCEDURE `init_map`(in count int)
BEGIN
declare jump int DEFAULT count;
WHILE jump>0 DO BEGIN
DECLARE i INT DEFAULT 1;
DECLARE c INT DEFAULT jump;
IF c>10000 THEN
SET c=10000;
END IF;
SET @sq=concat("INSERT INTO map(gp) VALUES (st_geomfromtext('POINT(",(rand()*50+75)," ",(rand()*50+75),")'))");
WHILE i<c DO
SET @sq=concat(@sq,",(st_geomfromtext('POINT(",(rand()*50+75)," ",(rand()*50+75),")'))");
SET i=i+1;
END WHILE;
SELECT @sq;
PREPARE s FROM @sq;
EXECUTE s;
DEALLOCATE PREPARE s;
SET jump=jump-c;
END;
END WHILE;
END
参考文档:https://blog.csdn.net/linux__xu/article/details/80956959
参考文档:https://www.52pojie.cn/thread-985857-1-1.html
参考文档:https://blog.csdn.net/huryer/article/details/93175633
参考文档:
https://blog.csdn.net/S2T11Enterprise/article/details/98735569?utm_medium=distribute.pc_relevant.none-task-blog-title-3&spm=1001.2101.3001.4242
https://blog.csdn.net/lu_wei_wei/article/details/87882209?utm_medium=distribute.pc_relevant.none-task-blog-BlogCommendFromMachineLearnPai2-1.control&depth_1-utm_source=distribute.pc_relevant.none-task-blog-BlogCommendFromMachineLearnPai2-1.control
https://blog.csdn.net/moooonn/article/details/84861176?utm_medium=distribute.pc_relevant.none-task-blog-BlogCommendFromMachineLearnPai2-1.control&depth_1-utm_source=distribute.pc_relevant.none-task-blog-BlogCommendFromMachineLearnPai2-1.control
create extension if not exists "uuid-ossp";
参考文档:https://blog.csdn.net/pengpengpeng85/article/details/78757484
参考文档:https://blog.csdn.net/zengcong2013/article/details/13016211
参考文档:https://blog.csdn.net/fgx_123456/article/details/78959231
参考文档:
https://www.jianshu.com/p/c1e9f30c88a0
https://blog.csdn.net/yuzhiqiang_1993/article/details/78366985
参考文档:https://stackoverflow.com/questions/43995886/gradle-could-not-target-platform-java-se-8-using-tool-chain-jdk-7-1-7
参考文档:https://blog.csdn.net/xiaoluoli88/article/details/79208347
repositories {
maven {
url "http://maven.springframework.org/release" }
maven {
url "https://maven.fabric.io/public" }
}
参考文档:https://blog.csdn.net/u011054333/article/details/84642534
参考文档:
https://www.runoob.com/docker/windows-docker-install.html
https://www.jianshu.com/p/e8c29cba9fae
https://www.cnblogs.com/minseo/p/11364032.html
参考文档:
https://blog.csdn.net/qq_41185868/article/details/91358808
https://www.jianshu.com/p/8106eb06f128
https://blog.csdn.net/renfeigui0/article/details/102543039
https://blog.csdn.net/blastblade/article/details/95725604
参考文档:https://blog.csdn.net/caoxuecheng001/article/details/85289901
点击地址:http://localhost:9014/swagger-ui/index.html?configUrl=/v3/api-docs/swagger-config#/
参考文档:https://www.cnblogs.com/niudaben/p/11874049.html
参考文档:
https://blog.csdn.net/qq_29291085/article/details/77489342
https://github.com/MicrosoftArchive/redis
参考文档:
https://github.com/conduktor/kafka-stack-docker-compose
https://www.jianshu.com/p/7633a8f3f559
https://blog.csdn.net/bay_bai/article/details/104799498
https://blog.csdn.net/Dongguabai/article/details/86536894?utm_medium=distribute.pc_relevant.none-task-blog-BlogCommendFromMachineLearnPai2-1.edu_weight&depth_1-utm_source=distribute.pc_relevant.none-task-blog-BlogCommendFromMachineLearnPai2-1.edu_weight
docker-compose -f zk-single-kafka-single.yml up
点击地址:https://mvnrepository.com/?cf_chl_jschl_tk=fde3d66a441bcc8dba7919f148612031ace86ec0-1587705184-0-AYEK0uvnISvv13zeqOsCNGNIeDYey8ApUt5aK0HGGgzQKmfFWcmzIWQMbwUtD8TDWlShru-hDI7rc5kszT8mQFyDGeu4PY2pLjDHcoV5bENB5MXCNjgmLIuXAKTA9TBryElOwBPOqJGAXDmwSQRd3qUSPbLVgC2Nbi4YIqxa1lB1OV9wS5HXCP-dd59VDnFLJjn-zv1cLeSode4e29_FcRAa_EQgRYAB0KTM81pcmoQ4-_Wv1tJ6CDuYk5Pk-2P9wiN9cBBBVoh_2jRHFkP26cl_mOFwZt8Mswmvrw52eRChpsMCEAPtuis1tzdPSPDk1vbL_QlRC-ZK6iDHxbIvzek
参考文档:https://docs.microsoft.com/en-us/rest/api/storageservices/common-rest-api-error-codes
参考文档:https://blog.csdn.net/belalds/article/details/80060296
参考文档:
https://developer.51cto.com/art/201904/595020.htm
https://www.jianshu.com/p/9a0e9ffa17dd
参考文档:https://juejin.cn/post/6844903621146968077
参考文档:
https://blog.csdn.net/setlilei/article/details/99211804
https://blog.csdn.net/qq_22177809/article/details/86592660
https://blog.csdn.net/qq_31896193/article/details/85256769
@Consumes({
MediaType.APPLICATION_JSON, MediaType.TEXT_XML })
@Produces({
ContentType.APPLICATION_JSON_UTF_8, ContentType.TEXT_XML_UTF_8 })
参考文档:https://www.zhihu.com/question/36411025
参考文档:https://www.cnblogs.com/codecat/p/10903936.html
List<Integer> ageList = studentList.stream().map(StudentInfo::getAge).distinct().collect(Collectors.toList());
参考文档:
https://blog.csdn.net/qq944484545/article/details/106201416
https://www.cnblogs.com/ericnie/p/13472870.html
参考文档:https://www.cnblogs.com/zdd-java/p/11269455.html
List<String> collect = Stream.of(listA, listB)
.flatMap(Collection::stream)
.distinct()
.collect(Collectors.toList());
https://element.eleme.cn/#/zh-CN
https://vuex.vuejs.org/zh/guide/actions.html
https://panjiachen.github.io/vue-element-admin-site/zh/guide/#vue-%E7%94%9F%E6%80%81%E5%9C%88
参考文档:
https://juejin.cn/post/6863241580753616903
https://blog.csdn.net/m_uncle/article/details/80428542
https://cn.vuejs.org/v2/guide/
参考文档:https://www.cnblogs.com/steamed-twisted-roll/p/11851658.html
参考文档:
https://blog.csdn.net/A873054267/article/details/96433758
https://blog.csdn.net/tq1711/article/details/108536819
<el-select v-model="value" placeholder="请选择" @change="change()">
<el-option v-for="item in options" :key="item.value" :label="item.label" :value="item.value">el-option>
el-select>
change(){
this.$forceUpdate()
},
参考文档:https://juejin.cn/post/6844903845642911752
参考文档:
https://blog.csdn.net/qq_27263045/article/details/82797176
https://blog.csdn.net/weixin_42508745/article/details/102541694
https://blog.csdn.net/AN0692/article/details/105528755
html
<el-table :data="xxx.aaa" stripe @row-click="getIndex">
<el-table-column label="姓名">
<template slot-scope="scope">
<el-form-item
:prop="`aaa.${scope.$index}.name`"
:rules="rules['persons.name']"
>
<el-input
v-model="scope.row.name"
size="mini"
>el-input>
el-form-item>
template>
el-table-column>
js
rules: {
"aaa.name": [
{
required: true, message: "请输入人员姓名", trigger: "blur" }
],
const rule1 = new Promise((resolve,reject) => {
this.$refs['xuForm'].validate(valid => {
if(valid){
resolve()
}else{
// reject('error submit!!')
console.log("error submit!!");
return false;
}
})
})
const rule2 = new Promise((resolve,reject) => {
this.$refs['jiaoForm'].validate(valid => {
if(valid){
resolve()
}else{
console.log("error submit!!");
return false;
}
})
})
Promise.all([rule1,rule2]).then(() =>{
//进行的操作
})
this.refs[formName].validateField(‘验证字段名’)
参考文档:
http://www.likecs.com/default/index/show?id=67174
https://blog.csdn.net/u012138137/article/details/85284109?depth_1-utm_source=distribute.pc_relevant.none-task&utm_source=distribute.pc_relevant.none-task
https://msd.misuland.com/pd/10675307942478067
<el-form>
<el-form-item>
<el-upload
ref="upload"
action="/as"
multiple
:http-request="handleUpload"
:auto-upload="false"
:limit="20">
<el-button size="small" type="primary">点击上传el-button>
<div slot="tip" class="el-upload__tip">只能上传jpg/png文件,且不超过500kbdiv>
el-upload>
el-form-item>
<el-form-item>
<el-button type="primary" @click="handlePush">发布el-button>
el-form-item>
el-form>
handleUpload(raw){
this.files.push(raw.file);
},
async handlePush(){
this.$refs.upload.submit() // 这里是执行文件上传的函数,其实也就是获取我们要上传的文件
let fd = new FormData();
fd.append('operator',this.username)
fd.append('reimment',"倪楚楚")
fd.append('deptname',"技术部")
fd.append('taxno',this.taxno)
this.files.forEach(function (file) {
fd.append('file', file, file.name); // 因为要上传多个文件,所以需要遍历一下才行
//不要直接使用我们的文件数组进行上传,你会发现传给后台的是两个Object
})
axios.post(process.env.BASE_API+'/file/moreFileUpload',fd).then(res=>{
if(res.data.status==='OK'){
console.log(res)
}
})
}
参考文档:
https://segmentfault.com/a/1190000013472316
https://www.liangzl.com/get-article-detail-12639.html
参考文档:https://www.jianshu.com/p/4257d342ca05
npm uninstall element-ui #先卸载
npm install element-ui -S #后安装
main.js
import "element-ui/lib/theme-chalk/index.css"; // 添加这句话
参考文档:https://segmentfault.com/q/1010000009645349
<p ref="chengshi" @click="goLink">fdsfdfsf<p>
methods:{
goLink:function(){
setTimeout(function(){
this.$router.push({
name: 'searchGoods'});
},5000);
}
}
参考文档:https://blog.csdn.net/weixin_38291260/article/details/89340535
类似于post请求,不会显示在地址栏里,name必填
//操作 路由跳转
this.$router.push({
name:'hello',
params:{
name:'word',
age:'11'
}
})
//读取 路由参数接收
this.name = this.$route.params.name;
this.age = this.$route.params.age;
类似于get请求,会显示在地址栏
参考文档:https://www.jianshu.com/p/6f28f5abee08
没有更新到视图上时
this.$set( target, key, value )
举例:
this.$set(
this.temp.list,
index,
this.temp.list[index]
);
替换list里下标为0的值
参考文档:https://www.jianshu.com/p/cf0a54374419
参考文档:https://blog.csdn.net/zy21131437/article/details/106937156/
参考文档:https://www.jianshu.com/p/fa6ce8e6b011
参考文档:https://juejin.cn/post/6844903593896574990#heading-2
参考文档:https://www.xuanmo.xin/details/2869
devServer: {
disableHostCheck: true
}
参考文档:https://segmentfault.com/a/1190000020230779?utm_source=tag-newest
参考文档:https://www.jb51.net/article/159904.htm
参考文档:
https://blog.csdn.net/video_dc/article/details/85447278
https://www.pianshen.com/article/4862818537/
参考文档:
https://m.656463.com/wenda/vuelnpmrunbuildhygzmyx_78
https://stackoverflow.com/questions/59348502/vue-js-vue-cli-performing-npm-run-build-compiles-css-for-image-opacity-to-1
参考文档:https://www.jianshu.com/p/c700ad221428
参考文档:
https://github.com/axuebin/articles/issues/39
https://juejin.cn/post/6844904116339261447
参考文档:https://github.com/pnpm/pnpm
npm install -g pnpm
参考文档:
https://www.cnblogs.com/taiyonghai/p/9402734.html
https://blog.csdn.net/weixin_43249693/article/details/82812056
参考文档:https://jingyan.baidu.com/article/f25ef2548fe643482d1b826f.html
参考文档:
https://blog.csdn.net/weixin_43861543/article/details/100606762
https://www.jb51.net/article/147994.htm
// 引入依赖包
import axios from 'axios'
import {
Message} from 'element-ui'
// REQUEST 请求异常拦截
axios.interceptors.request.use(config=> {
//========== 所有请求之前都要执行的操作 ==============
return config;
}, err=> {
//================== 错误处理 ====================
Message.error({
message: '请求超时!'});
return Promise.resolve(err);
})
// RESPONSE 响应异常拦截
axios.interceptors.response.use(data=> {
//============== 所有请求完成后都要执行的操作 ==================
// 第一种方式
// 根据返回的code值来做不同的处理(和后端约定)
switch (data.code) {
case '0':
// exp: 修复iPhone 6+ 微信点击返回出现页面空白的问题
if (isIOS()) {
// 异步以保证数据已渲染到页面上
setTimeout(() => {
// 通过滚动强制浏览器进行页面重绘
document.body.scrollTop += 1
}, 0)
}
// 这一步保证数据返回,如果没有return则会走接下来的代码,不是未登录就是报错
return data
// 需要重新登录
case 'SHIRO_E5001':
// 微信生产环境下授权登录
if (isWeChat() && IS_PRODUCTION) {
axios.get(apis.common.wechat.authorizeUrl).then(({
result }) => {
location.replace(global.decodeURIComponent(result))
})
} else {
// 否则跳转到h5登录并带上跳转路由
const search = encodeSearchParams({
next: location.href,
})
location.replace(`/user/login`)
}
// 不显示提示消息
data.description = ''
break
default:
}
// 若不是正确的返回code,且已经登录,就抛出错误
const err = new Error(data.description)
err.data = data
err.response = response
// 第二种方式,仅对200和error状态处理
if (data.status && data.status == 200 && data.data.status == 'error') {
Message.error({
message: data.data.msg});
return;
}
return data;
}, err=> {
//============== 错误处理 ====================
if (err && err.response) {
switch (err.response.status) {
case 400: err.message = '请求错误(400)'; break;
case 401: err.message = '未授权,请重新登录(401)'; break;
case 403: err.message = '拒绝访问(403)'; break;
case 404: err.message = '请求出错(404)'; break;
case 408: err.message = '请求超时(408)'; break;
case 500: err.message = '服务器错误(500)'; break;
case 501: err.message = '服务未实现(501)'; break;
case 502: err.message = '网络错误(502)'; break;
case 503: err.message = '服务不可用(503)'; break;
case 504: err.message = '网络超时(504)'; break;
case 505: err.message = 'HTTP版本不受支持(505)'; break;
default: err.message = `连接出错(${
err.response.status})!`;
}
} else {
err.message = '连接服务器失败!'
}
Message.err( {
message: err.message } )
return Promise.resolve(err);
})
官方文档:
https://lavyun.gitbooks.io/fastify/content/Logging.html
https://www.fastify.cn/docs/latest/Plugins/
https://github.com/fastify/fastify-cookie
官方文档:https://www.expressjs.com.cn/
参考文档:https://blog.csdn.net/wjqwjq666666/article/details/105412750
参考文档:https://blog.csdn.net/wang993828743/article/details/106563985/
参考文档:https://juejin.cn/post/6844903614918459406#heading-22
参考文档:https://www.cnblogs.com/jpfss/p/9105119.html
参考文档:
https://juejin.cn/post/6844903726201700365#heading-19
https://juejin.cn/post/6844903856489365518#heading-2
https://blog.csdn.net/idweiwei/article/details/80743286
https://blog.csdn.net/doinb_6/article/details/89098424
https://www.cnblogs.com/lizhao123/p/9528124.html
https://blog.csdn.net/QQ_Empire/article/details/90269568
参考文档:
https://segmentfault.com/a/1190000012376645
https://blog.csdn.net/weixin_41948075/article/details/96477937
参考文档:https://blog.csdn.net/chenmoquan/article/details/9037035
在ul或li内加入样式:list-style-position: inside;
参考文档:http://www.360doc.com/content/17/1110/16/11764545_702688437.shtml
参考文档:https://www.cnblogs.com/sk-3/archive/2019/07/23/11232750.html
参考文档:https://www.jianshu.com/p/96bc61012b90
var timestamp = Date.parse(new Date());
var timestamp=new Date().getTime();
var timestamp=new Date().getTime();(和二重复了)
var timestamp = (new Date()).valueOf() //1572173440709
参考文档:https://blog.csdn.net/weixin_34097242/article/details/87963676
在后台设置Access-Control-Max-Age来控制浏览器在多长时间内(单位s)无需在请求时发送预检请求
参考文档:https://segmentfault.com/q/1010000009895059
参考文档:https://my.oschina.net/jak/blog/745862?utm_source=debugrun&utm_medium=referral
参考文档:https://www.webhek.com/post/window-postmessage-api.html
参考文档:https://zhuanlan.zhihu.com/p/32332583
参考文档:https://www.cnblogs.com/Ry-yuan/p/6848197.html
参考文档:https://blog.csdn.net/qq_34626003/article/details/88243824
const img = new Image();
img.src = this.base64String;
const newWin = window.open("", "_blank");
newWin.document.write(img.outerHTML);
newWin.document.title = "流程图"
newWin.document.close();
参考文档:https://blog.csdn.net/mcj_2017/article/details/82115015
参考文档:
https://blog.csdn.net/Tyro_java/article/details/79772442?utm_source=blogxgwz3
https://blog.csdn.net/lgysjfs/article/details/83039906?utm_medium=distribute.pc_relevant_t0.none-task-blog-BlogCommendFromMachineLearnPai2-1.control&dist_request_id=7625160f-fcaa-4b2b-a8a3-8c4456f0d24b&depth_1-utm_source=distribute.pc_relevant_t0.none-task-blog-BlogCommendFromMachineLearnPai2-1.control
https://blog.csdn.net/weixin_42390302/article/details/109443294
npm config rm proxy
npm config rm https-proxy
yarn config set sass-binary-site http://npm.taobao.org/mirrors/node-sass
或者
npm config set sass-binary-site http://npm.taobao.org/mirrors/node-sass
$ npm install -g cnpm --registry=https://registry.npm.taobao.org
cnpm install node-sass --save-dev
cnpm install sass-loader --save-dev
//卸载 node-sass
npm uninstall node-sass
//然后安装最新版本(5.0之前)
npm install [email protected]
参考文档:https://www.jianshu.com/p/21f905fc7e19
参考文档:https://blog.csdn.net/qiansg123/article/details/80129453
参考文档:
https://blog.csdn.net/weixin_41869700/article/details/81092391
https://my.oschina.net/chengpengvb/blog/1832469?tdsourcetag=s_pctim_aiomsg
https://www.jb51.net/html5/685312.html
https://www.jianshu.com/p/8e88e23e2409
参考文档:https://blog.csdn.net/kingvslucy/article/details/80816622?utm_medium=distribute.pc_relevant_t0.none-task-blog-searchFromBaidu-1.control&depth_1-utm_source=distribute.pc_relevant_t0.none-task-blog-searchFromBaidu-1.control
官方文档:https://www.npmjs.com/package/taro-ui
参考文档:https://www.jianshu.com/p/ba9036adaf5a?tdsourcetag=s_pctim_aiomsg
参考文档:https://juejin.cn/post/6844903509272297480
参考文档:
https://jingyan.baidu.com/article/75ab0bcba47c19d6864db2cf.html
https://www.jianshu.com/p/ed2bb33e59a7
参考文档:http://www.6699fa.cn/excel10/jiao18120402.html
参考文档:https://baijiahao.baidu.com/s?id=1609219777116011612&wfr=spider&for=pc
参考文档:
https://baijiahao.baidu.com/s?id=1609206178826018034&wfr=spider&for=pc
https://jingyan.baidu.com/article/d621e8dae59d3a6965913fe0.html
参考文档:https://zhidao.baidu.com/question/276932076.html
参考文档:https://jingyan.baidu.com/article/642c9d3421381d644b46f750.html
参考文档:https://zhidao.baidu.com/question/194051199.html
点击地址:https://svg.wxeditor.com/
点击地址:http://sfz.uzuzuz.com/?region=110101&birthday=20000307&sex=1&num=5&r=61
点击地址:
https://1024tools.com/uuid
http://www.uuid.online/
点击地址:https://support.microsoft.com/zh-cn/windows/%E9%87%8D%E7%BD%AE%E6%88%96%E9%87%8D%E6%96%B0%E5%AE%89%E8%A3%85-windows-10-cd352bd8-4cb6-411a-f2f5-1814bd8d453c
点击地址:https://www.processon.com/
参考文档:https://jingyan.baidu.com/article/3c343ff7f372920d3679636b.html
参考文档:https://blog.csdn.net/sunshine_lyn/article/details/86476712
参考文档:https://www.jb51.net/softs/732920.html
参考文档:
https://blog.csdn.net/huaishitou/article/details/102877808
https://www.cnblogs.com/panchanggui/p/10272835.html
参考文档:https://blog.csdn.net/wangchao1988ok/article/details/45193489
参考文档:https://blog.csdn.net/qq_39136928/article/details/81240894#comments
参考文档:https://blog.csdn.net/zzzgd_666/article/details/81126822
参考文档:https://blog.csdn.net/Sunshine_wz/article/details/102950809
参考文档:https://blog.csdn.net/Hubz131/article/details/103296764
参考文档:https://blog.csdn.net/qq_38295166/article/details/80565844?utm_medium=distribute.pc_relevant_t0.none-task-blog-BlogCommendFromMachineLearnPai2-1.edu_weight&depth_1-utm_source=distribute.pc_relevant_t0.none-task-blog-BlogCommendFromMachineLearnPai2-1.edu_weight
参考文档:https://blog.csdn.net/qq_27327261/article/details/81502929
-- 杀死进程端口
netstat -aon|findstr "8086"
taskkill /PID 9160 /f
参考文档:https://blog.csdn.net/u013310037/article/details/108427835
参考文档:https://blog.csdn.net/auccy/article/details/103349088
参考文档:https://blog.csdn.net/linda_417/article/details/51719013h
参考文档:https://segmentfault.com/a/1190000007530568