小编Don*_*mmy的帖子

使用休眠6.0.10验证会导致EachPattern中的ConstraintDefinitionException

当我尝试将@EachPatternList用于:

@EachPattern(
   regexp = "^[a-z]+",
   message = "Invalid"
)
public List<String> getTestItems()
{
    return Arrays.asList( "aaaaa" );
}
Run Code Online (Sandbox Code Playgroud)

我收到以下错误:

Caused by: javax.validation.ConstraintDefinitionException: HV000243: Constraint cz.jirutka.validator.collection.constraints.EachPattern references constraint validator type cz.jirutka.validator.collection.CommonEachValidator, but this validator is defined for constraint type java.lang.annotation.Annotation.
    at org.hibernate.validator.internal.engine.constraintvalidation.ClassBasedValidatorDescriptor.of(ClassBasedValidatorDescriptor.java:48)
    at org.hibernate.validator.internal.engine.constraintvalidation.ConstraintValidatorDescriptor.forClass(ConstraintValidatorDescriptor.java:49)
    at org.hibernate.validator.internal.metadata.core.ConstraintHelper.lambda$getDefaultValidatorDescriptors$6(ConstraintHelper.java:1001)
    at java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:193)
    at java.util.Spliterators$ArraySpliterator.forEachRemaining(Spliterators.java:948)
    at java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:481)
    at java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:471)
    at java.util.stream.ReduceOps$ReduceOp.evaluateSequential(ReduceOps.java:708)
    at java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234)
    at java.util.stream.ReferencePipeline.collect(ReferencePipeline.java:499)
    at org.hibernate.validator.internal.metadata.core.ConstraintHelper.getDefaultValidatorDescriptors(ConstraintHelper.java:1002)
    at org.hibernate.validator.internal.metadata.core.ConstraintHelper.lambda$getAllValidatorDescriptors$2(ConstraintHelper.java:730)
    at java.util.concurrent.ConcurrentHashMap.computeIfAbsent(ConcurrentHashMap.java:1660)
    at org.hibernate.validator.internal.metadata.core.ConstraintHelper$ValidatorDescriptorMap.computeIfAbsent(ConstraintHelper.java:1043)
    at org.hibernate.validator.internal.metadata.core.ConstraintHelper$ValidatorDescriptorMap.access$100(ConstraintHelper.java:1033)
    at org.hibernate.validator.internal.metadata.core.ConstraintHelper.getAllValidatorDescriptors(ConstraintHelper.java:730)
    at org.hibernate.validator.internal.metadata.core.ConstraintHelper.findValidatorDescriptors(ConstraintHelper.java:744)
    at org.hibernate.validator.internal.metadata.core.ConstraintHelper.assertValidationAppliesToParameterSetUpCorrectly(ConstraintHelper.java:923)
    at org.hibernate.validator.internal.metadata.core.ConstraintHelper.lambda$isConstraintAnnotation$5(ConstraintHelper.java:864)
    at …
Run Code Online (Sandbox Code Playgroud)

java validation spring hibernate spring-boot

2
推荐指数
1
解决办法
646
查看次数

为什么 Windows 上的 bash 会说“没有这样的文件或目录”?

我正在尝试在 Windows 上使用 bash 运行我的 shell 脚本,但它说没有这样的文件。该文件肯定存在(我从命令行检查了它)

# Tried all of these, and they all fail
bash C:/Users/myuser/Testing/my_script.sh
bash /c/Users/myuser/Testing/my_script.sh
bash -c /c/Users/myuser/Testing/my_script.sh
bash C:\Users\myuser\Testing\my_script.sh
Run Code Online (Sandbox Code Playgroud)

我只是得到:

/bin/bash: C:/Users/myuser/Testing/my_script.sh: 没有那个文件或目录

该文件确实存在:

dir C:\myuser\Testing\my_script.sh
Run Code Online (Sandbox Code Playgroud)

驱动器 C 中的卷是 Windows 卷序列号是 XXXX-XXXX

C:\myuser\Testing\my_script.sh 目录

08/15/2019 10:42 AM 7,783 my_script.sh
1 文件 7,783 字节
0 目录 370,855,380,416 字节空闲

bash 版本:

bash --version
Run Code Online (Sandbox Code Playgroud)

GNU bash,版本 4.4.19(1)-release (x86_64-pc-linux-gnu)
版权所有 (C) 2016 Free Software Foundation, Inc.
许可证 GPLv3+:GNU GPL 版本 3 或更高版本http://gnu.org/licenses /gpl.html

这是免费软件;您可以自由更改和重新分发它。
在法律允许的范围内,不提供任何保证。 …

windows bash shell windows-10 windows-subsystem-for-linux

2
推荐指数
1
解决办法
8435
查看次数

找到开始字符串的制表符数量的最佳/最快方法是什么?

我想在字符串的开头找到选项卡的数量(当然我希望它是快速运行的代码 ;) )。这是我的想法,但不确定这是否是最好/最快的选择:

//The regular expression
var findBegTabs = /(^\t+)/g;

//This string has 3 tabs and 2 spaces: "<tab><tab><space>something<space><tab>"
var str = "      something  ";

//Look for the tabs at the beginning
var match = reg.exec( str );

//We found...
var numOfTabs = ( match ) ? match[ 0 ].length : 0;
Run Code Online (Sandbox Code Playgroud)

另一种可能性是使用循环和 charAt:

//This string has 3 tabs and 2 spaces: "<tab><tab><space>something<space><tab>"
var str = "      something  ";

var numOfTabs = 0;
var start = 0;

//Loop and count …
Run Code Online (Sandbox Code Playgroud)

javascript regex optimization

1
推荐指数
1
解决办法
3625
查看次数

在Android Studio中,如何获取类可以实现的所有方法的弹出窗口(并添加它们)?

如果我创建了一个实现另一个类的类(例如class MyFragment extends Fragment),当我开始在类中输入时,它不会给我父类方法的代码完成.如何显示或获取可以从中选择的弹出窗口?

例如,MyFragment输入public void onCre中没有显示任何内容.(但是在输入整个方法之后,它编译得很好.)

java android intellij-idea code-completion android-studio

1
推荐指数
1
解决办法
1390
查看次数

如何匹配可以以查询字符串结尾的URL中的文件扩展名?

我想在所有的以下网址的文件扩展名匹配达问号.因此URL#4将匹配"file.pdf"中的pdf,而不匹配"otherfile.exe"中的"exe".

http://www.someplace.com/directory/file.pdf
http://www.someplace.com/directory/file.pdf?otherstuff=true
http://www.someplace.com/directory/file.pdf?other=true&more=false
http://www.someplace.com/directory/file.pdf?other=true&more=false&value=otherfile.exe
Run Code Online (Sandbox Code Playgroud)

我该怎么做呢?

我尝试过这个,但它不起作用:

([^\.]+)(\?|[^\?]$)+
Run Code Online (Sandbox Code Playgroud)

javascript php regex

1
推荐指数
1
解决办法
1326
查看次数

即使发送到虚假地址,PHPMailer也会返回true

我需要知道PHPMailer是否无法发送电子邮件.但即使发送到假电子邮件地址也会返回true:

$phpmailer = new PHPMailer( true );
$phpmailer->setFrom( "myemail@myemailladdy.com", "myemail@myemailladdy.com" );

//This is definitely not reachable
$phpmailer->addAddress( "fake@shdsabdasdiuahsdiuhaiduhasidsjdfake.com", "IJustPressedRandomKeys" ); 

$phpmailer->Subject = "fake";
$phpmailer->Body = "fake";
echo "Is Mail: " . $phpmailer->IsMail();

//This prints "1"
echo "Was Sent: " . $phpmailer->send();
Run Code Online (Sandbox Code Playgroud)

为什么这个返回1/true?

(当电子邮件有效时,我收到电子邮件,因此PHPMailer设置正确)

php phpmailer

1
推荐指数
1
解决办法
1671
查看次数

当用户点击后退按钮时,仍然可以设置由前一次点击设置样式的css元素

当有人点击或悬停在元素上时,我为元素设置了CSS样式.在移动版Safari上,当用户点击它以转到新页面然后点击浏览器的后退按钮时,它仍然以"点击"颜色显示.有办法阻止这个吗?

.button:hover, .button:active
{
    color: red;
}
Run Code Online (Sandbox Code Playgroud)

html javascript css html5 css3

1
推荐指数
1
解决办法
112
查看次数

如何用另一个分支完全替换master及其所有提交?

我一直在尝试master用另一个分支替换repo的分支,但我尝试的每一种方式,它都保留了不在另一个分支中的提交.例如,另一个分支有121个提交,但在命令之后(两个集合都在下面),master显示216个提交!

尝试#1

#Replacing master with otherBranch branch
git checkout otherBranch
git merge -s ours master
git checkout master
git merge otherBranch 
git push
Run Code Online (Sandbox Code Playgroud)

尝试#2

git checkout otherBranch
git push git@github.com:remoteRepo :master

#Also tried
git checkout otherBranch
git push git@github.com:remoteRepo +otherBranch:master
Run Code Online (Sandbox Code Playgroud)

两者都以相同的结果结束.

那么如何用其他分支完全替换master呢?

git

1
推荐指数
1
解决办法
66
查看次数

如何中止来自 ContainerRequestFilter 的 JSON 请求?

我想在出现错误时中止请求并返回 JSON。但下面的代码只是返回一个字符串说"Unexpected 'U'"(这不是我的信息)

我如何让它通过 JSON 响应中止?

requestContext.abortWith(
    Response.status( Response.Status.UNAUTHORIZED ).entity(
        e.getMessage()
    ).type(
        MediaType.APPLICATION_JSON
    ).build()
);
Run Code Online (Sandbox Code Playgroud)

java json jax-rs jersey jakarta-ee

1
推荐指数
1
解决办法
1314
查看次数

如何将具有列表中相同值的两个字段的对象组合到一个简化列表中?

我有这个类的对象列表:

class Item
{
    private String name;
    private String parentName;
    private Integer someValue;
    private Double anotherValue;

    public Item() {}

    //...elided getters/setters...
}
Run Code Online (Sandbox Code Playgroud)

我有一个列表,其中包含以下值:

//PSEUDO CODE (Not JavaScript, but using JSON is easier to follow)
List<Item> items = [
    {
        "name": "Joe",
        "parentName": "Frank",
        "someValue": 10,
        "anotherValue": 15.0
    },
    {
        "name": "Joe",
        "parentName": "Frank",
        "someValue": 40,
        "anotherValue": 0.5
    },
    {
        "name": "Joe",
        "parentName": "Jack",
        "someValue": 10,
        "anotherValue": 10.0
    },
    {
        "name": "Jeff",
        "parentName": "Frank",
        "someValue": 10,
        "anotherValue": 10.0
    }
];
Run Code Online (Sandbox Code Playgroud)

我希望将其合并到此列表中: …

java java-8

1
推荐指数
1
解决办法
72
查看次数