小编ams*_*ams的帖子

如何配置Postgres + Spring + Quartz?

我正在尝试为quartz jdbc store配置Spring 3.2 + Quartz 2.1 + PostgreSQL.但是我得到了下面的例外情况.我已经为石英创建了所有必需的postgres表.

弹簧配置.

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:context="http://www.springframework.org/schema/context"
    xmlns:tx="http://www.springframework.org/schema/tx" xmlns:aop="http://www.springframework.org/schema/aop" xmlns:task="http://www.springframework.org/schema/task"
    xsi:schemaLocation="
        http://www.springframework.org/schema/task http://www.springframework.org/schema/task/spring-task-3.2.xsd
        http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.2.xsd
         http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-3.2.xsd
        http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.2.xsd
            http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-3.2.xsd
    ">

    <context:annotation-config />
    <context:component-scan base-package="com.example.spring.task.quartz"></context:component-scan>


    <bean id="dataSource" class="org.springframework.jdbc.datasource.DriverManagerDataSource">
        <property name="driverClassName" value="org.postgresql.Driver" />
        <property name="url" value="jdbc:postgresql://localhost:5432/springquartz" />
        <property name="username" value="springquartz" />
        <property name="password" value="password" />
    </bean>

    <tx:annotation-driven mode="proxy" transaction-manager="transactionManager" />
    <bean id="transactionManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
        <property name="dataSource" ref="dataSource" />
    </bean>

    <bean id="entityManagerFactory" class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean">
        <property name="dataSource" ref="dataSource" />
        <property name="persistenceUnitName" value="testUnit" />
        <property …
Run Code Online (Sandbox Code Playgroud)

spring quartz-scheduler

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

何时使用Spring @ConfigurationCondition vs. @Condition?

Spring 4有两个新的注释@Condition,@ConfigurationConditon用于控制是否将bean添加到spring应用程序上下文中.JavaDoc没有提供足够的上下文/大图来理解用例@ConfigurationCondition.

什么时候应该@ConfigurationCondition@Condition

public interface ConfigurationCondition extends Condition {

    /**
     * Returns the {@link ConfigurationPhase} in which the condition should be evaluated.
     */
    ConfigurationPhase getConfigurationPhase();

    /**
     * The various configuration phases where the condition could be evaluated.
     */
    public static enum ConfigurationPhase {

        /**
         * The {@link Condition} should be evaluated as a {@code @Configuration} class is
         * being parsed.
         *
         * <p>If the condition does not match at this …
Run Code Online (Sandbox Code Playgroud)

java spring

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

什么时候使用 Mono.never()?

我已经阅读了reactor.core.publisher.MonoFrom project reactor 类的 Javadocs但是我仍然不明白拥有该Mono.never()方法的意义何在。

人们会使用哪些示例用例Mono.never()

java spring reactive-programming project-reactor spring-webflux

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

为什么状态已完成的pod仍会出现在kubctl get pods中?

我已经执行了"Kubernetes Up and Running"一书中的示例,其中运行了具有工作队列的pod,然后创建了一个k8s作业,其中5个pod用于消耗队列中的所有工作.我已经复制了下面的yaml api对象.

我的期望是,一旦k8s工作完成,那么它的pod将被删除,但kubectl get pods -o wide显示pod仍然存在,即使它报告0/1容器准备好了,他们似乎仍然分配了ip地址,见下面的输出.

  • 何时将完成的工作吊舱从输出中删除kubectl get pods为什么在吊舱中的所有容器完成后不正确?
  • 当pod像IP地址一样完成消息时,是否会消耗任何资源,或者信息是打印出来的?

在所有pod消耗掉所有消息之后从kubectl输出.

kubectl get pods -o wide
NAME              READY     STATUS      RESTARTS   AGE       IP           NODE
consumers-bws9f   0/1       Completed   0          6m        10.32.0.35   gke-cluster1-default-pool-3796b2ee-rtcr
consumers-d25cs   0/1       Completed   0          6m        10.32.0.33   gke-cluster1-default-pool-3796b2ee-rtcr
consumers-jcwr8   0/1       Completed   0          6m        10.32.2.26   gke-cluster1-default-pool-3796b2ee-tpml
consumers-l9rkf   0/1       Completed   0          6m        10.32.0.34   gke-cluster1-default-pool-3796b2ee-rtcr
consumers-mbd5c   0/1       Completed   0          6m        10.32.2.27   gke-cluster1-default-pool-3796b2ee-tpml
queue-wlf8v       1/1       Running     0          22m       10.32.0.32   gke-cluster1-default-pool-3796b2ee-rtcr
Run Code Online (Sandbox Code Playgroud)

执行了以下三个k8s api调用,这些调用是从书籍样本中剪切和粘贴的.

运行具有工作队列的pod

apiVersion: extensions/v1beta1
kind: ReplicaSet …
Run Code Online (Sandbox Code Playgroud)

kubernetes

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

内置 gradle 插件的版本号是多少?

在我的 gradle 构建文件中,我有以下插件块

plugins {
    `java-library`
    jacoco
    checkstyle
}
Run Code Online (Sandbox Code Playgroud)

这些都没有指定版本,但一切正常。

假设一个项目使用 gradle 6.0 和 gradle 包装器,但系统安装了 gradle 5.0。

问题:

  • 如果我运行 gradle wrapper ./gradlew build,将执行 gradle 6.0 中的 java 插件。这是对还是错?
  • 如果我运行 system gradle gradle build,将执行 gradle 5.0 中的 java 插件。这是对还是错?
  • 这些插件是捆绑到 gradle 发行版本身还是按需从 gradle 插件门户下载?
  • 由于未设置插件版本,构建是否被认为是不可重现的(就像在 maven 中一样)?
  • 应该设置或关闭插件版本的 gradle 最佳实践是什么?

java gradle

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

如果测试失败,如何配置 testcontainers 以保持数据库容器运行?

使用测试容器时,正常行为是在测试完成时由于通过或失败而关闭容器。

有没有办法配置测试容器,以便在测试失败时保留数据库容器以帮助调试?

java testing junit integration-testing testcontainers

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

Flyway 如何锁定 postgres 架构?

我将 Flyway 与 Postgres 一起使用,我注意到如果我的 tomcat 服务器正在运行,并且我尝试执行 a ,DROP SCHEMA foo那么直到 tomcat 关闭时它才起作用。我假设 Flyway 有某种机制可以在运行后阻止对模式的修改。在 Flyway 中如何阻止其他客户端修改架构。

flyway

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

如何使用SpringMVC + Jackson应用程序防止XSS攻击?

站脚本备忘单有许多防止 XSS 攻击的规则。我想在我的 Web 应用程序中实现这些建议,该应用程序使用 Spring MVC + Jackson + JPA + Hibernate Bean Validation。作为示例,请考虑以下与我的应用程序中的代码类似的代码。

public class MessageJson {
    @NotEmpty // Bean Validation annotation  
    private String title; 

    @NotEmpty
    private String body; 

    // ... etc getters / setters
}

public class BolgPostController 
{ 
     
     @RequestMapping(value="messages",method=RequestMethod.POST) 
     public void createMessage(@Valid @RequestBody MessageJson message)
     {
           // **Question** How do I check that the message title and body don't contain 
           // nasty javascripts and other junk that should not be there? 

           // Call services …
Run Code Online (Sandbox Code Playgroud)

security xss spring-mvc jackson

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

如何查看origin/master超前的提交消息?

当git告诉我我的本地分支在master之后时,我如何告诉git打印出我背后的日志消息.例如,在下面的情况下,如何查看我在master上没有的2个提交源/主站的日志消息?

git status
# On branch master
# Your branch is behind 'origin/master' by 2 commits, and can be fast-forwarded.
#
nothing to commit, working directory clean
Run Code Online (Sandbox Code Playgroud)

git

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

如何使用现有的pom.xml将第三方文件发布到远程maven仓库?

我有一些第三方罐子,我想上传到我的nexus maven repo,到目前为止,我已经找到了两种方法.

mvn deploy:deploy-file -DgroupId=<group-id> \
  -DartifactId=<artifact-id> \
  -Dversion=<version> \
  -Dpackaging=<type-of-packaging> \
  -Dfile=<path-to-file> \
  -DrepositoryId=<id-to-map-on-server-section-of-settings.xml> \
  -Durl=<url-of-the-repository-to-deploy>
Run Code Online (Sandbox Code Playgroud)

我期待第三方库经常更新,当有安全更新/发布时,可能会更频繁地说四分之一.

上面两种方法都是手动的,你必须输入一个长命令或点击它来实现它.我更喜欢一个不是特定产品或需要冗长命令行选项的简单解决方案.

有没有可能写一个maven pom.xml,只是通过这样做发布第三方.tar.gz mvn deploy

我正在使用maven 3.0.5

更新根据下面的radai答案为我工作的示例pom.xml.

java nexus maven-3 maven

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