小编x80*_*486的帖子

AsciiDoc"引用链接"(如在Markdown中)

参考样式链接非常有用,因为我可以通过名称来引用链接.例如,在Markdown我习惯做类似的事情:

The [Web site][tag-web-site] references...blah.

[tag-web-site]: https://web-site-url.tld
Run Code Online (Sandbox Code Playgroud)

...它将根据tag-web-site参考创建一个链接.

有什么办法可以在AsciiDoc中模仿这个功能吗?我试过但到目前为止我找不到任何东西.

markdown asciidoc

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

Spring Security绕过URL或过滤器

我有一个只暴露REST API的Spring Boot应用程序.我需要保护它并且我使用基于令牌的方法 - 特别是JWT.

到目前为止,这是我实施的:

//
// The Spring Security configuration class
@EnableGlobalAuthentication
public class SecurityConfig extends WebSecurityConfigurerAdapter {
  @Override
  protected void configure(final HttpSecurity http) throws Exception {
    http
        .csrf().disable()
        .authorizeRequests()
          .antMatchers("/api/login", "/api/logout").permitAll()
          .antMatchers("/api/**").authenticated()
          .anyRequest().authenticated()
        .and()
          .addFilterBefore(new JwtFilter(), BasicAuthenticationFilter.class)
          .sessionManagement()
          .sessionCreationPolicy(SessionCreationPolicy.STATELESS);
  }
}
Run Code Online (Sandbox Code Playgroud)
//
// The JWT filter class to check for the token in the HTTP request (headers)
public final class JwtFilter extends GenericFilterBean {
  private final Logger logger = LoggerFactory.getLogger(this.getClass());

  @Override
  public void doFilter(final ServletRequest request, final …
Run Code Online (Sandbox Code Playgroud)

java spring-security spring-boot

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

Javax 验证实现

我正在尝试为局部变量创建我的自定义注释,但我只是不明白注释是如何在代码中实现的,@NotNull或者@Null是如何在代码中实际实现的。我查看了实际文件,这是@NotNull

@Target({ METHOD, FIELD, ANNOTATION_TYPE, CONSTRUCTOR, PARAMETER })
@Retention(RUNTIME)
@Documented
@Constraint(validatedBy = { })
public @interface NotNull {

    String message() default "{ javax.validation.constraints.NotNull.message }";

    Class<?>[] groups() default { };

    Class<? extends Payload>[] payload() default { };

    @Target({ METHOD, FIELD, ANNOTATION_TYPE, CONSTRUCTOR, PARAMETER })
    @Retention(RUNTIME)
    @Documented
    @interface List {
        NotNull[] value();
    }
}
Run Code Online (Sandbox Code Playgroud)

但是我没有看到任何地方可以检查是否有东西null实际检查在哪里进行?

java validation annotations

4
推荐指数
2
解决办法
5574
查看次数

是否可以在发送消息时取消消息?

进程在1分钟后A发送请求(让我们称之为).但有1分钟取消它.Bsend_afterrequestB

可以B发送cancelA和防止这一时间跨度内发送该消息?

erlang

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

Spring WS 客户端 - 使用服务器和客户端证书进行身份验证

我需要能够对 SOAP 服务进行“客户端证书”身份验证。

\n\n

我正在使用 Spring WS。我有: a my.key、 amyCA.pem和 a myClient.crt

\n\n

这是我的相关 Java 代码(我知道它仍然很混乱,但我只是想让它先工作):

\n\n
public TheResponse doIt(TheRequest request) {\n  log.info("Sending request...");\n  try {\n    InputStream is = new FileInputStream(new File("src/main/resources/keystore.jks"));\n    KeyStore keyStore = KeyStore.getInstance(KeyStore.getDefaultType());\n    keyStore.load(is, "keystore!passwd".toCharArray());\n    is.close();\n    KeyManagerFactory keyManagerFactory = KeyManagerFactory.getInstance(KeyManagerFactory.getDefaultAlgorithm());\n    keyManagerFactory.init(keyStore, keyStorePassword.toCharArray());\n\n    InputStream is1 = new FileInputStream(new File("src/main/resources/truststore.jks"));\n    KeyStore trustStore = KeyStore.getInstance(KeyStore.getDefaultType());\n    trustStore.load(is1, "truststore!passwd".toCharArray());\n    is1.close();\n    TrustManagerFactory trustManagerFactory = TrustManagerFactory.getInstance(TrustManagerFactory.getDefaultAlgorithm());\n    trustManagerFactory.init(trustStore);\n\n    HttpsUrlConnectionMessageSender messageSender = new HttpsUrlConnectionMessageSender();\n    messageSender.setKeyManagers(keyManagerFactory.getKeyManagers());\n    messageSender.setTrustManagers(trustManagerFactory.getTrustManagers());\n    setMessageSender(messageSender);\n\n    return (TheResponse) getWebServiceTemplate().marshalSendAndReceive(request,\n …
Run Code Online (Sandbox Code Playgroud)

ssl soap web-services spring-ws keystore

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

在 Spring Boot WebFlux 上检索路径变量(函数式方法)

假设我有这个路由器定义:

@Component
class PersonRouter(private val handler: PersonHandler) {
  @Bean
  fun router(): RouterFunction<ServerResponse> = router {
    ("/api/people" and accept(MediaType.APPLICATION_JSON_UTF8)).nest {
      GET("/{id}") { handler.findById(it) }
    }
  }
Run Code Online (Sandbox Code Playgroud)

然后这个处理程序:

@Component
@Transactional
class PersonHandler(private val repository: PersonRepository) {
  private companion object : KLogging()

  @Transactional(readOnly = true)
  fun findById(req: ServerRequest): Mono<ServerResponse> {
    logger.info { "${req.method()} ${req.path()}" }
    val uuid = ? // req.pathContainer().elements().last().value()
    return ServerResponse.ok()
        .contentType(MediaType.APPLICATION_JSON_UTF8)
        .body(BodyInserters.fromObject(repository.findById(uuid)))
        .switchIfEmpty(ServerResponse.notFound().build())
  }
}
Run Code Online (Sandbox Code Playgroud)

如何@PathVariable id: String在不使用正则表达式、字符串繁重等方面进行黑魔法的情况下访问标识符(典型的a 是什么@RestControllerServerRequest

kotlin spring-boot spring-webflux

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

"模式匹配"对Int子句(分支)不起作用

我在Kotlin(我开始学习)中有这段代码:

package io.shido.learning

import java.time.Instant

fun typeCheck(any: Any): Any = when (any) {
  (any is Int && any < 10) -> "(small) integer"
  is Int -> "integer"
  is Double -> "double"
  is String -> "string"
  else -> "another Any"
}

fun main(args: Array<String>) {
  println("type check for: 5 (${typeCheck(5)})")
  println("type check for: 20 (${typeCheck(20)})")
  println("type check for: 56.0 (${typeCheck(56.0)})")
  println("type check for: \"a string\" (${typeCheck("a string")})")
  println("type check for: Instant (${typeCheck(Instant.now())})")
}
Run Code Online (Sandbox Code Playgroud)

...所以我期待那typeCheck(5)回归,(small) integer而不是integer像目前那样. …

kotlin

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

确定Erlang二进制文件大小的复杂性

我知道,对于列表,我们必须遍历整个列表然后确定它的大小?

在Erlang中确定二进制文件大小的复杂性是多少?

erlang complexity-theory

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

@RequestMapping如何在Spring Boot中内部工作?

@RestController
@RequestMapping("/employee")
public class Employee {
  @RequestMapping("/save")
  public void saveEmployee() {
    // saving employee
  }
}
Run Code Online (Sandbox Code Playgroud)

@RequestMapping内部如何将请求映射到saveEmployee方法?

spring spring-boot spring-restcontroller request-mapping

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

有没有办法让sqlc生成可以使用pgxpool的代码

sqlc我最近开始使用jackc/pgx/v5. 我也希望能够使用,但是在流程接管后pgxpool确实没有什么好的方法可以使用。例如,这就是我初始化连接池的方式:pgxpoolsqlc

var err error
var pool *pgxpool.Pool
if pool, err = pgxpool.New(context.Background(), url); err != nil {
    log.Panicf(...)
}
defer pool.Close()

queries := db.New(pool) // queries *Queries
Run Code Online (Sandbox Code Playgroud)

基本上,queries每当需要数据库交互时,我只是将其提供给整个应用程序,但我不会传递pool.

此外,由于sqlc自动管理连接,我不确定使用类似以下代码片段的含义,因为涉及很多手动步骤并且有些重叠:

ctx := context.Background()

conn, _ := pool.Acquire(ctx)
tx, _ := conn.Begin(ctx)
defer tx.Rollback(ctx)

queries := db.New(pool)
queries.WithTx(tx).OneOfTheAutogeneratedQueries(ctx)

defer conn.Release()
tx.Commit(ctx)
Run Code Online (Sandbox Code Playgroud)

有人有同样的情况吗?有更好的方法来解决这个问题吗?我假设自动生成的代码将提供一种相应的管理事务的机制,但看起来除了以编程方式关闭资源之外,sqlc仍然需要池的引用才能创建类型。pgx.Tx

go pgx sqlc

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