在gradle中发布到存储库时,有没有办法获得下一个版本?
例如,如果我的3.0.1存储库中有版本,我想要发布的版本3.0.2.
ivy有一个ant命名的任务,buildnumber它完全是这样的:
<project xmlns:ivy="antlib:org.apache.ivy.ant"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<target name="ivyBuildNumber" description="Use ivy get the next build number">
<ivy:buildnumber
resolver="url-chain"
organisation="${ivy.organisation}"
module="${ivy.module}"
revision="${version.base}"/>
<echoproperties prefix="ivy.new."/>
</target>
Run Code Online (Sandbox Code Playgroud)
有没有办法这样做gradle?如果不能如何ivy从gradle中访问任务ant?
在我的build.gradle呼唤中ant
ant.importBuild 'build.xml'
Run Code Online (Sandbox Code Playgroud) 我想dependency在gradle中打印最后一个版本.
我以这种方式添加了我的依赖:
compile 'test:test:+'
Run Code Online (Sandbox Code Playgroud)
现在我想打印我的依赖版本,因为我想知道我正在使用哪个版本.
我正在以这种方式使用它:
gradle dependencyInsight --configuration compile --dependency test:test
Run Code Online (Sandbox Code Playgroud)
但我的输出是这样的:
+--- test:test:+ -> project : (*)
Run Code Online (Sandbox Code Playgroud)
无论如何,我可以得到我的依赖的真实版本,而不是+?
我有一个SimpleTest:
@RunWith(SpringRunner.class)
@SpringBootTest(classes = SimpleTestConfig.class)
public class SimpleTest {
@Test
public void test() {
assertThat(true);
}
}
Run Code Online (Sandbox Code Playgroud)
以及此测试的配置:
@SpringBootApplication
@ComponentScan(basePackageClasses = {
SimpleTestConfig.class,
Application.class
},
excludeFilters = @ComponentScan.Filter(
type = FilterType.ASSIGNABLE_TYPE,
classes = Starter.class))
public class SimpleTestConfig {
}
Run Code Online (Sandbox Code Playgroud)
我试图排除Starter类
package application.starters;
import org.springframework.stereotype.Component;
import javax.annotation.PostConstruct;
@Component
public class Starter {
@PostConstruct
public void init(){
System.out.println("initializing");
}
}
Run Code Online (Sandbox Code Playgroud)
而应用程序类看起来是这样的:
package application;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import static org.springframework.boot.SpringApplication.run;
@SpringBootApplication
public class Application {
public …Run Code Online (Sandbox Code Playgroud) 我正在尝试为Lock我正在处理的行设置一个直到下次提交:
entityManager.createQuery("SELECT value from Table where id=:id")
.setParameter("id", "123")
.setLockMode(LockModeType.PESSIMISTIC_WRITE)
.setHint("javax.persistence.lock.timeout", 10000)
.getSingleResult();
Run Code Online (Sandbox Code Playgroud)
我认为应该发生的是,如果两个线程同时尝试写入数据库,一个线程将在另一个线程之前到达更新操作,第二个线程应该等待10秒然后抛出PessimisticLockException.
但是,无论超时设置如何,线程都会挂起,直到另一个线程完成.
看看这个例子:
database.createTransaction(transaction -> {
// Execute the first request to the db, and lock the table
requestAndLock(transaction);
// open another transaction, and execute the second request in
// a different transaction
database.createTransaction(secondTransaction -> {
requestAndLock(secondTransaction);
});
transaction.commit();
});
Run Code Online (Sandbox Code Playgroud)
我预计在第二个请求中,事务将等到超时设置然后抛出PessimisticLockException,但它会永远死锁.
Hibernate以这种方式向db生成我的请求:
SELECT value from Table where id=123 FOR UPDATE
Run Code Online (Sandbox Code Playgroud)
在这个答案中我看到Postgres只允许SELECT FOR UPDATE NO WAIT将超时设置为0,但是不可能以这种方式设置超时. …
无论如何我可以在gradle中创建两个模块项目,并自己触发每个模块的构建吗?
Root project 'Example'
Jenkinsfile
\--- Project ':SubProject'
Jenkinsfile
Run Code Online (Sandbox Code Playgroud)
我希望jenkins只在已经更改的模块中触发构建.
例如:
如果我SubProject改变了,那么只会SubProject执行它自己的Jenkinsfile.
我很长时间都在寻找这个选项......
正如您在其他问题中所看到的,没有任何简单的方法可以实现这一点.
是否有任何Jenkins pipeline或plugin能处理呢?
java app在大多数项目中,运行模式验证的方法是使用该配置(使用 spring 时):
spring.jpa.hibernate.ddl-auto=validate
Run Code Online (Sandbox Code Playgroud)
我遇到了一个问题,我需要在运行期间的特定时间验证我的架构,有什么方法可以实现吗?
我看到 hibernate 使用 来管理它AbstractSchemaValidator,我将 spring 与 hibernate 一起使用,并且我没有找到任何如何处理它的信息,
我发现的唯一的东西是如何在 hibernate 中使用注释以编程方式验证数据库模式?
,但在旧版本中已被删除spring-boot
<dependency>
<groupId>org.springframework.data</groupId>
<artifactId>spring-data-jpa</artifactId>
<version>2.0.4.RELEASE</version>
</dependency>
Run Code Online (Sandbox Code Playgroud)
有任何想法吗?
当我尝试Specification在我的数据库中使用他的名字搜索 enum 时Spring @Repository,我收到以下异常:
Caused by: java.lang.IllegalArgumentException: Parameter value [HELLO] did not match expected type [application.springEnum.Hello (n/a)]
Run Code Online (Sandbox Code Playgroud)
但是在数据库中,枚举保存为VARCHAR(255)为什么我可以用 搜索枚举String,为什么需要通过枚举类型?
DTO类
@Entity
@Getter
@Setter
@NoArgsConstructor
@AllArgsConstructor
@Builder
public class DTO {
@Id
private String id;
@Enumerated(EnumType.STRING)
private Hello helloEnum; // My Enum
}
Run Code Online (Sandbox Code Playgroud)
数据库连接器
@Repository
public interface Connector extends JpaRepository<DTO, String>, JpaSpecificationExecutor<DTO> {
}
Run Code Online (Sandbox Code Playgroud)
起动机
@Component
public class Starter {
@Autowired
private Connector connector;
@PostConstruct
public void init(){
// Create DTO entity
DTO …Run Code Online (Sandbox Code Playgroud) 使用多个网络部署 docker-compose 时,只有第一个接口可以访问外界
version: "3.9"
services:
speedtest:
build:
context: .
dockerfile: speedtest.Dockerfile
tty: true
networks:
- eth0
- eth1
networks:
eth0:
eth1:
Run Code Online (Sandbox Code Playgroud)
例如,在容器内运行 pingping -I eth0 google.com工作正常,但是运行ping -I eth1 google.com会得到结果
PING google.com (142.250.200.238) from 172.21.0.2 eth1: 56(84) bytes of data.
From c4d3b238f9a1 (172.21.0.2) icmp_seq=1 Destination Host Unreachable
From c4d3b238f9a1 (172.21.0.2) icmp_seq=2 Destination Host Unreachable
Run Code Online (Sandbox Code Playgroud)
知道如何在两个网络上都有到互联网的出口吗?尝试了多种组合来创建网络,包括外部网络、带有自定义配置的桥接器等......
更新
larsks回答后,使用ip route addeth1 并运行tcpdump -i any数据包正确进入:
11:26:12.098918 eth1 Out IP 8077ec32b69d > dns.google: ICMP echo …Run Code Online (Sandbox Code Playgroud) 我的团队Spring Boot Admin用来控制我们spring application,
在Spring Boot Admin我们可以选择更改logger级别Runtime,
我们为每个task(Thread)都有一个单独的记录器,如果我们只想查看一个线程的控制台日志,我们关闭所有其他线程记录器,问题是,每个记录器将它的输出既为STDOUT,也为某个文件,我们要关闭只有标准输出输出.
log4j2.xml配置示例:
<Loggers>
<Logger name="task1" level="info">
<AppenderRef ref="Console"/>
<AppenderRef ref="File"/>
</Logger>
<Logger name="task2" level="info">
<AppenderRef ref="Console"/>
<AppenderRef ref="File"/>
</Logger>
</Loggers>
Run Code Online (Sandbox Code Playgroud)
我们尝试了很多解决方案:
我在 Kubernetes 集群中遇到了oauth2 代理和 Ingress Nginx(最新版本)的问题,其中X-Auth-Request标头在标准 oauth 身份验证流程中未传递到客户端。我专门使用 Azure 作为身份验证提供程序。
这是我的 oauth 代理配置的相关部分:
pass_access_token = true
pass_authorization_header = true
pass_user_headers = true
set_xauthrequest = true
Run Code Online (Sandbox Code Playgroud)
当我显式调用 时/oauth2/auth,我会按预期获得标头。但是,在标准 OAuth2 身份验证流程中,任何请求都不会返回任何标头。
这种情况有点类似于这里的另一个问题:Oauth2-Proxy do not pass X-Auth-Request-Groups header,但就我而言,我没有收到任何X-Auth-Request标头,除非我/oauth2/auth直接调用。
我还尝试将以下代码片段添加到我的应用程序 Ingress 配置中,但没有成功:
nginx.ingress.kubernetes.io/configuration-snippet: |
auth_request_set $email $upstream_http_x_auth_request_email;
access_by_lua_block {
if ngx.var.email ~= "" then
ngx.req.set_header("X-Auth-Request-Email", ngx.var.email)
end
}
Run Code Online (Sandbox Code Playgroud)
我已经完成了多种配置,阅读了大量博客文章,并搜索了 GitHub 问题,但一直无法解决这个问题。有谁对可能导致这种行为的原因有任何见解吗?
java ×6
gradle ×3
hibernate ×3
jpa ×3
spring ×3
android ×2
spring-boot ×2
ant ×1
build-tools ×1
docker ×1
enums ×1
ivy ×1
jenkins ×1
kubernetes ×1
log4j2 ×1
macos ×1
networking ×1
nginx ×1
oauth-2.0 ×1
postgresql ×1
spring-test ×1