I want to build a docker image using a GitHub action, migrating from TeamCity.
In the build script, I want to tag the image with a combination of branch and commit, e.g. master.ad959de. Testing that locally, I get that information like this:
git_branch=`git symbolic-ref --short HEAD`
git_hash=`git rev-parse --short HEAD`
docker_version=${git_branch}.${git_hash}
Run Code Online (Sandbox Code Playgroud)
This is the relevant part of the GitHub action:
name: CI
on: [push]
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- name: Create docker image
run: ./docker-build.sh …Run Code Online (Sandbox Code Playgroud) 我有一个使用spring-security的spring-boot应用程序.安全配置分为多个实例WebSecurityConfigurerAdapter.
我有一个配置注销的一般方法:
@Override
protected void configure(HttpSecurity http) throws Exception {
// configure logout
http
.logout()
.logoutUrl("/logout")
.invalidateHttpSession(true)
.addLogoutHandler((request, response, authentication) -> {
System.out.println("logged out 1!");
})
.permitAll();
// ... more security configuration, e.g. login, CSRF, rememberme
}
Run Code Online (Sandbox Code Playgroud)
WebSecurityConfigurerAdapter除了添加另一个LogoutHandler之外,还有另外一个我几乎什么都不想做的事情:
@Override
protected void configure(HttpSecurity http) throws Exception {
// configure logout
http
.logout()
.logoutUrl("/logout")
.addLogoutHandler((request, response, authentication) -> {
System.out.println("logged out 2!");
});
}
Run Code Online (Sandbox Code Playgroud)
两种configure()方法都被调用.但是,如果我注销,则仅LogoutHandler调用第一个.更改@Order两种配置不会改变结果.
我的配置中缺少什么?
在我的 spring-boot 2.3 应用程序中,我使用了一个简单的数据方法DatabaseClient:
fun getCurrentTime(): Mono<LocalDateTime> =
databaseClient
.execute("SELECT NOW()")
.asType<LocalDateTime>()
.fetch()
.first()
}
Run Code Online (Sandbox Code Playgroud)
使用 spring-boot 2.4(和 spring 5.3 和 spring-data-r2dbc 1.2),org.springframework.data.r2dbc.core.DatabaseClient不推荐使用 spring-data-r2dbc,取而代之的org.springframework.r2dbc.core.DatabaseClient是 spring-r2dbc - 它具有不同的 API。
调整它非常简单 - 除了 kotlin 扩展asType,它不是新的 DatabaseClientExtensions 的一部分。
fun getCurrentTime(): Mono<LocalDateTime> =
databaseClient
.sql("SELECT NOW()")
.map { row: Row ->
row.get(0, LocalDateTime::class.java)!!
}
.one()
Run Code Online (Sandbox Code Playgroud)
这些扩展是其他地方还是我如何使用具体化类型参数进行转换?
我开始使用Spring 3.2的新MVC Testframework,并且无法为我的所有测试用例获取406个HTTP响应代码.
测试用例很简单
public class LocationResouceTest {
@Autowired
private WebApplicationContext wac;
private MockMvc mockMvc;
@Before
public void setup() {
this.mockMvc = MockMvcBuilders.webAppContextSetup(this.wac).build();
}
@Test
public void testGetLocationByPlzPattern() throws Exception {
// here I need to define the media type as a static var from MediaType
this.mockMvc.perform(get("/someurl?someparam=somevalue")).andExpect(status().isOk());
}
}
Run Code Online (Sandbox Code Playgroud)
相应的资源是
@Controller
// here I need to define the media type as string
@RequestMapping(value = "/someurl", produces = "application/json; charset=UTF-8")
public class LocationResource {
@ResponseBody
@RequestMapping(method = RequestMethod.GET)
public ArrayList<DTO> getAllIndex(@RequestParam("someparam") …Run Code Online (Sandbox Code Playgroud) 为了BufferedImage从spring-mvc中搜索最少量的代码(在服务类中绘制)Controller,我想出了以下内容:
@GetMapping(value = "/image", produces = "image/png")
public StreamingResponseBody image() {
BufferedImage canvas = service.createImage();
return outputStream -> ImageIO.write(canvas, "png", outputStream);
}
Run Code Online (Sandbox Code Playgroud)
到目前为止,非常好 - 使用HTML中的图像通过<img src="/image">工作正常.
但是,spring根本不会发送任何Content-Type标题.与X-Content-Type-Options: nosniff响应中的服务一起,当直接打开图像URL时,这会导致浏览器窗口中的垃圾.
如何以最弹性友好的方式提供内容类型标题(即不HttpServletResponse直接使用)?
当我链接多个zipWhen调用时,结果将是 aTuble2<Tuple2<Foo, Bar>, Bam>而不是 a Tuple3<Foo, Bar, Bam>。随后的每一次这种情况都会变得更糟zipWhen。
例子:
val getFoo()
.zipWhen { foo ->
getBar(foo)
}
.zipWhen { fooBar ->
getBam(fooBar.t1, fooBar.t2)
}
.doOnNext { fooBarBam ->
log.debug { "foo: ${fooBarBam.t1.t1}" }
log.debug { "bar: ${fooBarBam.t1.t2}" }
log.debug { "bam: ${fooBarBam.t2}" }
}
Run Code Online (Sandbox Code Playgroud)
获取 doOnNext 的最优雅且可重用的方法是什么Tubple3?
java ×4
spring ×4
kotlin ×2
spring-mvc ×2
git ×1
github ×1
security ×1
spring-boot ×1
testing ×1