使用start.spring.io初始化项目
添加了WEB,JPA,H2依赖项,然后尝试运行MainApplication.java使用Jdk 9并获得以下错误日志
. ____ _ __ _ _
/\\ / ___'_ __ _ _(_)_ __ __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
\\/ ___)| |_)| | | | | || (_| | ) ) ) )
' |____| .__|_| |_|_| |_\__, | / / / /
=========|_|==============|___/=/_/_/_/
:: Spring Boot :: (v1.5.10.RELEASE)
2018-02-26 16:23:33.973 INFO …Run Code Online (Sandbox Code Playgroud) 如果我不返回会发生什么,din或者dout实际上我正在读一本书,其中作者返回流引用
istream & operator>>(istream &din,vector &a)
{
for(int i=0;i<size;i++)
din>>a.v[i];
return din;
}
ostream & operator<<(ostream &dout,vector &a)
{
dout<<"("<<a.v[0];
for(int i=1;i<size;i++)
dout<<", "<<a.v[i];
dout<<")";
return dout;
}
Run Code Online (Sandbox Code Playgroud) 在 2021.2 中一切正常,但当在 2021.3 打开同一个项目时,出现以下错误
http://0.0.0.0/ during a previous attempt. This failure was cached in the local repository and resolution will not be reattempted until the update interval of maven-default-http-blocker has elapsed or updates are forced. Original error: Could not transfer metadata com.domain.sub-domain.project:private-commons:1.0.0-SNAPSHOT/maven-metadata.xml from/to maven-default-http-blocker (http://0.0.0.0/): transfer failed for http://0.0.0.0/com/domain/sub-domain/project/private-repo/1.0.0-SNAPSHOT/maven-metadata.xml
Cannot resolve junit:junit:4.12
Cannot resolve org.apache.camel:camel-test:2.23.0
Cannot resolve com.amazonaws:aws-java-sdk-glacier:1.11.415
Run Code Online (Sandbox Code Playgroud)
在字符串函数中,如substring()
"hello".substring(0, 3)
Run Code Online (Sandbox Code Playgroud)
返回hel
而0-3索引包含地狱
并在正则表达式Matcher的end()方法
mat = Pattern.compile("test").matcher("test");
mat.find();
System.out.println(mat.end());
Run Code Online (Sandbox Code Playgroud)
返回4,而第一个匹配在索引3结束
我只是好奇为什么java以这种方式工作
我正在寻找一种基于过期令牌的真实性更新jwt令牌的机制。这是我尝试过的
import com.auth0.jwt.JWT;
import com.auth0.jwt.JWTVerifier;
import com.auth0.jwt.algorithms.Algorithm;
import com.auth0.jwt.exceptions.JWTVerificationException;
import com.auth0.jwt.exceptions.TokenExpiredException;
import com.auth0.jwt.interfaces.DecodedJWT;
import constants.AppConstants;
import java.io.UnsupportedEncodingException;
import java.time.ZoneId;
import java.time.ZonedDateTime;
import java.util.Date;
public class JwtUtil {
private static JWTVerifier verifier;
private static String secret = AppConstants.JWT_KEY;
static {
Algorithm algorithm = null;
try {
algorithm = Algorithm.HMAC256(secret);
} catch (UnsupportedEncodingException e) {
e.printStackTrace();
}
verifier = JWT.require(algorithm)
.withIssuer("Issuer")
.build();
}
public static String getSignedToken(Long userId) {
Algorithm algorithm = null;
try {
algorithm = Algorithm.HMAC256(secret);
} catch (UnsupportedEncodingException e) …Run Code Online (Sandbox Code Playgroud) 我已经使用 start.spring.io 初始化了 spring boot 项目并添加了 WEB、JPA、H2 依赖项。
Pom文件
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.example</groupId>
<artifactId>demo</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>jar</packaging>
<name>demo</name>
<description>Demo project for Spring Boot</description>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>1.5.10.RELEASE</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<java.version>1.8</java.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-security</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>com.h2database</groupId>
<artifactId>h2</artifactId>
<!-- <scope>runtime</scope> -->
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
Run Code Online (Sandbox Code Playgroud)
应用程序属性
spring.h2.console.enabled=true
security.basic.enabled=false
Run Code Online (Sandbox Code Playgroud)
演示应用程序.java
@SpringBootApplication
public …Run Code Online (Sandbox Code Playgroud) 我想对我的 get 请求进行负载测试
http://localhost:8080/v1/synonyms/project/?keyword=dealer
Run Code Online (Sandbox Code Playgroud)
和测试方法是
@task(2)
def get_synonym(self):
response = self.client.get("/v1/synonyms/project/")
print("Response status code:", response.status_code)
print("Response content:", response.text)
Run Code Online (Sandbox Code Playgroud) 我知道${para:[start]:[length]}和$@符号,但我无法找出如何${var: -1}评估最后一个参数.
在编写测试时,我遇到了克隆对象的需求。通过 apache-commons 找到了 2 个 Utill 类,然后我试图找到我应该使用哪一个,我试图通过读出两个 API 文档来找到差异,但没有找到我应该使用哪一个
根据文档: 根据可用的属性 getter 和 setter 克隆 bean,即使 bean 类本身没有实现 Cloneable。
疑问:我应该在 DTO 克隆上使用它吗?
SerializationUtils clone() API 文档
根据文档:
使用序列化深度克隆对象。
这比在对象图中的所有对象上手动编写克隆方法要慢很多倍。然而,对于复杂的对象图,或者对于那些不支持深度克隆的对象图,这可能是一个简单的替代实现。当然,所有对象都必须是可序列化的。
疑问:我应该将它用于 DTO 和实体对象吗?或仅适用于实体
在我的数据库中有一个varchar(255)列,对于某些记录,它包含空值,当我解雇它时
SELECT * FORM my_table where some_column <> NULL;
Run Code Online (Sandbox Code Playgroud)
没有任何回报
但什么时候被解雇了
SELECT * FORM my_table where some_column IS NOT NULL;
Run Code Online (Sandbox Code Playgroud)
我得到了想要的记录
你能解释一下它们之间的主要区别以及何时使用<>和!=运算符.
有时我会编写一些小脚本,用于管理数据库中的记录或生成一些用于报告目的的数据。
大多数时候我们使用Long类型作为用户实体的 ID。如果我执行以下操作:
List<Long> listOfLong = Arrays.asList(1L, 2L, 3L);
System.out.println(listOfLong.contains(2));
Run Code Online (Sandbox Code Playgroud)
它返回,false但为此:
System.out.println(integers.contains(2L));
Run Code Online (Sandbox Code Playgroud)
它返回true。
我们不应该得到这样的编译时错误吗?