小编xen*_*ide的帖子

perl Client-SSL-Warning:未验证对等证书

我在使用perl screenscraper到HTTPS站点时遇到问题.在调试中,我运行了以下内容:

print $res->headers_as_string;
Run Code Online (Sandbox Code Playgroud)

在输出中,我有以下行:

Client-SSL-Warning: Peer certificate not verified
Run Code Online (Sandbox Code Playgroud)

有没有办法可以自动接受这个证书,或者这不是问题吗?

#!/usr/bin/perl 
use LWP::UserAgent; 
use Crypt::SSLeay::CTX; 
use Crypt::SSLeay::Conn; 
use Crypt::SSLeay::X509; 
use LWP::Simple qw(get);

my $ua  = LWP::UserAgent->new; 
my $req = HTTP::Request->new(GET => 'https://vzw-cat.sun4.lightsurf.net/vzwcampaignadmin/');
my $res = $ua->request($req);

print $res->headers_as_string;
Run Code Online (Sandbox Code Playgroud)

输出:

Cache-Control: no-cache
Connection: close
Date: Tue, 01 Jun 2010 19:28:08 GMT
Pragma: No-cache
Server: Apache
Content-Type: text/html
Expires: Wed, 31 Dec 1969 16:00:00 PST
Client-Date: Tue, 01 Jun 2010 19:28:09 GMT
Client-Peer: 64.152.68.114:443
Client-Response-Num: 1
Client-SSL-Cert-Issuer: /O=VeriSign Trust Network/OU=VeriSign, Inc./OU=VeriSign …
Run Code Online (Sandbox Code Playgroud)

perl ssl http certificate lwp

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

我的$ _; 如果隐含$ _则做任何事情

我认为答案是肯定的,但我只是想确定一下.所以,如果我有

sub something {
    my $_;
    my @array = ...;
    while ( @array ) {
        say;
    }
}
Run Code Online (Sandbox Code Playgroud)

是否my $_;实际上有效地将传递给参数的参数词汇化?

在这个特殊的情况下,我正在使用DZP :: UnusedVarsTests,它抱怨我没有使用过my $_;,我怀疑它是一个bug,因为我在它隐含的情况下使用它.

perl lexical-scope

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

测试Catalyst REST API的最简单方法是什么?

我正在使用Catalyst :: Controller :: REST构建RESTful Web服务.通常对于Web测试我使用Test :: WWW :: Mechanize,但这似乎更适合"GET/POST HTML RPC"测试.是否有任何测试模块可以使用基本身份验证来测试HTTP,使用GET/POST/PUT/DELETE等和JSON轻松?也许是与Catalyst/PSGI很好地集成的东西,所以我不必启动网络服务器?

testing perl json http catalyst

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

如何在perl中取消导入函数?

我正在尝试删除导入的符号,以便它们作为对象中的方法不可用,但no似乎不起作用,也许我不理解否,或者还有另一种方法.

use 5.014;
use warnings;
use Test::More;

# still has carp after no carp
package Test0 {
    use Carp qw( carp );
    sub new {
        my $class = shift;
        my $self  = {};

        carp 'good';

        bless $self, $class;
        return $self;
    }
    no Carp;
}

my $t0 = Test0->new;

ok( ! $t0->can('carp'), 'can not carp');

# below passes correctly
package Test1 {
    use Carp qw( carp );
    use namespace::autoclean;

    sub new {
        my $class = shift;
        my $self  = …
Run Code Online (Sandbox Code Playgroud)

perl

6
推荐指数
2
解决办法
683
查看次数

Hibernate UUID作为UUID类型

尝试使用UUID作为我的PostgreSQL和H2的id,当前的例外是H2

java.lang.IllegalArgumentException: Can not set java.util.UUID field com.lm.model.Task.id to java.lang.String
at sun.reflect.UnsafeFieldAccessorImpl.throwSetIllegalArgumentException(UnsafeFieldAccessorImpl.java:167)
at sun.reflect.UnsafeFieldAccessorImpl.throwSetIllegalArgumentException(UnsafeFieldAccessorImpl.java:171)
at sun.reflect.UnsafeObjectFieldAccessorImpl.set(UnsafeObjectFieldAccessorImpl.java:81)
at java.lang.reflect.Field.set(Field.java:758)
at org.hibernate.property.DirectPropertyAccessor$DirectSetter.set(DirectPropertyAccessor.java:122)
at org.hibernate.tuple.entity.AbstractEntityTuplizer.setIdentifier(AbstractEntityTuplizer.java:381)
at org.hibernate.persister.entity.AbstractEntityPersister.setIdentifier(AbstractEntityPersister.java:4751)
at org.hibernate.event.internal.AbstractSaveEventListener.performSave(AbstractSaveEventListener.java:184)
at org.hibernate.event.internal.AbstractSaveEventListener.saveWithGeneratedId(AbstractSaveEventListener.java:137)
at org.hibernate.jpa.event.internal.core.JpaPersistEventListener.saveWithGeneratedId(JpaPersistEventListener.java:84)
at org.hibernate.event.internal.DefaultPersistEventListener.entityIsTransient(DefaultPersistEventListener.java:206)
at org.hibernate.event.internal.DefaultPersistEventListener.onPersist(DefaultPersistEventListener.java:149)
at org.hibernate.event.internal.DefaultPersistEventListener.onPersist(DefaultPersistEventListener.java:75)
at org.hibernate.internal.SessionImpl.firePersist(SessionImpl.java:811)
at org.hibernate.internal.SessionImpl.persist(SessionImpl.java:784)
at org.hibernate.internal.SessionImpl.persist(SessionImpl.java:789)
at org.hibernate.jpa.spi.AbstractEntityManagerImpl.persist(AbstractEntityManagerImpl.java:1181)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:483)
at org.springframework.orm.jpa.ExtendedEntityManagerCreator$ExtendedEntityManagerInvocationHandler.invoke(ExtendedEntityManagerCreator.java:342)
at com.sun.proxy.$Proxy68.persist(Unknown Source)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:483)
at org.springframework.orm.jpa.SharedEntityManagerCreator$SharedEntityManagerInvocationHandler.invoke(SharedEntityManagerCreator.java:289)
at com.sun.proxy.$Proxy68.persist(Unknown Source)
at org.springframework.data.jpa.repository.support.SimpleJpaRepository.save(SimpleJpaRepository.java:389)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at …
Run Code Online (Sandbox Code Playgroud)

java postgresql hibernate h2 spring-data

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

如果注释在不同的行上,则在字段之间需要一个空行?

基本上我想要不同的样式取决于注释计数,例如

class Foo {
  @Autowire private MyService myService;
  @Autowire private MyOtherService service;

  ...
 }
Run Code Online (Sandbox Code Playgroud)

但如果我有更多的注释需要一个空格

@Entity
class Bar {
  @Id
  @NotNull
  @Column(...)
  private Long id;

  @NotNull
  @NotEmpty
  @Column(...)
  private String description;
}
Run Code Online (Sandbox Code Playgroud)

我可以强制IDEA为这两种风格格式化Java吗?

java code-formatting intellij-idea

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

IDEA Groovy测试类已经存在

IDEA给我的groovy类警告`class"MyClassTest"已经存在于"my.class.package"中.在运行测试时,它似乎也没有很好地保持课程更新.我将添加一个保证失败的断言,或者成功,直到稍后才会识别它(后来到目前为止似乎是随意的).鉴于我有maven测试正确传递和运行,我怀疑这只是一个IDEA配置问题

这是我的 pom.xml

<?xml version="1.0" encoding="UTF-8"?>
 <project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
     xmlns="http://maven.apache.org/POM/4.0.0"
     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.xenoterracide</groupId>
<artifactId>rpf</artifactId>
<version>0.1.0</version>

<parent>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-parent</artifactId>
    <version>1.1.9.RELEASE</version>
</parent>

<build>
    <plugins>
        <plugin>
            <groupId>org.codehaus.gmavenplus</groupId>
            <artifactId>gmavenplus-plugin</artifactId>
            <version>1.2</version>
            <executions>
                <execution>
                    <goals>
                        <goal>addSources</goal>
                        <goal>addTestSources</goal>
                        <goal>generateStubs</goal>
                        <goal>compile</goal>
                        <goal>testGenerateStubs</goal>
                        <goal>testCompile</goal>
                        <goal>removeStubs</goal>
                        <goal>removeTestStubs</goal>
                    </goals>
                </execution>

            </executions>
            <configuration>
                <testSources>
                    <testSource>
                        <directory>${project.basedir}/src/test/groovy</directory>
                        <includes>
                            <include>**/*.groovy</include>
                        </includes>
                    </testSource>
                </testSources>
            </configuration>
        </plugin>
    </plugins>
</build>

<dependencies>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-data-rest</artifactId>
    </dependency>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-data-jpa</artifactId>
    </dependency>
    <dependency>
        <groupId>org.springframework.data</groupId>
        <artifactId>spring-data-jpa</artifactId>
        <version>1.8.0.DATAJPA-622-SNAPSHOT</version>
    </dependency>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-logging</artifactId>
    </dependency>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-test</artifactId>
    </dependency>
    <!--
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-security</artifactId>
    </dependency> …
Run Code Online (Sandbox Code Playgroud)

java groovy intellij-idea maven intellij-14

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

带有分页的Spring JPA存储库中的自定义查询

我尝试用Spring Boot实现JPA Repository它工作正常.现在,如果我尝试在接口中实现自定义查询,使用@Query Annotation扩展JpaRepository,它可以很好地返回Bean的列表.(使用NamedQuery).现在,当我尝试使用分页自定义方法/查询时,它不起作用.

代码:

控制器:

@RequestMapping("/custompages/{pageNumber}")
public String getAllEmployeesUsingNamedQueryWithPaging(@PathVariable Integer pageNumber,Model model)
{
    Page<Employee> page = employeeService.getAllEmployeesUsingNamedQueryWithPaging(pageNumber);

    System.out.println("current page "+page);
    System.out.println("current page content"+page.getContent());

     int current = page.getNumber() + 1;
    int begin = Math.max(1, current - 5);
    int end = Math.min(begin + 10, page.getTotalPages());

    model.addAttribute("empList", page.getContent());
    model.addAttribute("empPages", page);
    model.addAttribute("beginIndex", begin);
    model.addAttribute("endIndex", end);
    model.addAttribute("currentIndex", current);

    return "employeeWorkbench";
}
Run Code Online (Sandbox Code Playgroud)

服务

@Override
public Page<Employee> getAllEmployeesUsingNamedQueryWithPaging(Integer  
pageNumber) {

    PageRequest pageRequest =
            new PageRequest(pageNumber - 1, PAGE_SIZE, 
    Sort.Direction.ASC, "id");
    return   
employeeDao.getAllEmployeesUsingNamedQueryWithPaging(pageRequest);
}
Run Code Online (Sandbox Code Playgroud)

@Transactional
public …
Run Code Online (Sandbox Code Playgroud)

hibernate spring-mvc data-paging spring-data-jpa spring-boot

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

如何排除特定findbugs规则的包

我已经尝试了几次迭代,但这是我最新的

<?xml version="1.0" encoding="UTF-8"?>
<FindBugsFilter>
  <Match>
    <Package name="~com[.]xenoterracide[.]rpf[.]([.].*)?"/>
    <Bug code="SE_TRANSIENT_FIELD_NOT_RESTORED"/>
  </Match>
</FindBugsFilter>
Run Code Online (Sandbox Code Playgroud)

最终我想得到所有匹配的包(glob语法)

com.xenoterracide.rpf.*.ui 或者只是 com.xenoterracide.rpf.*

INFO] The field com.xenoterracide.rpf.character.ui.CharactersView.editDialog is transient but isn't set by deserialization [com.xenoterracide.rpf.character.ui.CharactersView] In CharactersView.java SE_TRANSIENT_FIELD_NOT_RESTORED
[INFO] The field com.xenoterracide.rpf.character.ui.CharactersView.messenger is transient but isn't set by deserialization [com.xenoterracide.rpf.character.ui.CharactersView] In CharactersView.java SE_TRANSIENT_FIELD_NOT_RESTORED
[INFO] The field com.xenoterracide.rpf.character.ui.CharactersView.repo is transient but isn't set by deserialization [com.xenoterracide.rpf.character.ui.CharactersView] In CharactersView.java SE_TRANSIENT_FIELD_NOT_RESTORED
[INFO] The field com.xenoterracide.rpf.ui.NavigationBar.messages is transient but isn't set by deserialization [com.xenoterracide.rpf.ui.NavigationBar] In NavigationBar.java SE_TRANSIENT_FIELD_NOT_RESTORED
[INFO] The field com.xenoterracide.rpf.ui.components.EditDialog.repository …
Run Code Online (Sandbox Code Playgroud)

java regex findbugs

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

有没有办法将进程的标准输出发送到 SLF4J?

我基本上是在做以下事情:

Process process = new ProcessBuilder().command( ... ).start();
InputStream stdout = process.getInputStream();
LoggerFactory.getLogger( this.class ).debug...?
Run Code Online (Sandbox Code Playgroud)

有没有办法将 写入InputStream记录器,以便它由我的日志记录设置管理?或者我应该采取另一种方法来捕获流程输出吗?

更新:我已经重写了这个,因为我刚刚意识到我读Process/ProcessBuilder错了API,那getInputStream()就是 STDOUT

更新 2理想情况下,实现这一目标的方式将允许我在 stdout/stderr 出现时(一次一行)处理它们,而不是稍后处理。

java slf4j

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