小编Yud*_*rya的帖子

什么是Kotlin支持领域?

作为一名Java开发人员,支持领域的概念对我来说有点陌生.鉴于:

   class Sample {
        var counter = 0 // the initializer value is written directly to the backing field
        set(value) {
            if (value >= 0) field = value
        }
    }
Run Code Online (Sandbox Code Playgroud)

这个支持领域有什么用?Kotlin博士说:Kotlin的课程不能有字段.但是,有时在使用自定义访问器时需要有一个支持字段.为什么?在setter中使用属性名称本身的区别是什么.

    class Sample {        
        var counter = 0
        set(value) {
            if (value >= 0) this.counter = value // or just counter = value?
        }
    }
Run Code Online (Sandbox Code Playgroud)

android kotlin kotlin-android-extensions

73
推荐指数
3
解决办法
8919
查看次数

如何在openpyxl中冻结整个标题行?

如何在openpyxl中冻结整个标题行?到目前为止,我只能冻结列:

# only freeze the column (freeze vertically)
cell = ws.cell('{}{}'.format(col, row_idx+1))  
worksheet.freeze_panes = cell
Run Code Online (Sandbox Code Playgroud)

python openpyxl

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

.NET Core中的SOAP?

你如何在.NET Core中使用SOAP?.Net Core中是否有Apache CXF的等价物(不只是简单的SOAP客户端,而是全功能堆栈)?

很抱歉,如果这是一个非常基本的问题,我到目前为止的搜索并没有给出任何明确的答案.

.net c# soap web-services .net-core

20
推荐指数
3
解决办法
3万
查看次数

WebStorm 中的 NextJS 支持吗?

Webstorm(或 IntelliJ IDEA Ultimate)路线图中是否有计划为 Next.js 提供一流的支持?就像目前支持 Angular 和普通 React 一样。

intellij-idea webstorm next.js

14
推荐指数
1
解决办法
6907
查看次数

如何在Spring Webflux/WebClient中设置事件循环池大小?

在Vert.X等多反应堆框架中,我们可以设置事件循环线程的数量,例如:

final VertxOptions vertxOptions = new VertxOptions();
vertxOptions.setEventLoopPoolSize(16);
final Vertx myVertx = Vertx.vertx(vertxOptions);
Run Code Online (Sandbox Code Playgroud)

如何在Spring Boot 2 WebFlux/WebClient中进行等效操作?

java spring spring-boot project-reactor spring-webflux

11
推荐指数
1
解决办法
3361
查看次数

Kotlin内联属性的用例是什么?

由于属性的gettersetter通常不具有作为参数或reified类型的函数,使用inline属性的好处/用例是什么?

如果好处是降低与方法调用相关的成本,为什么不默认使所有属性getter/setter内联?

Kotlin内联属性

例如.

val foo: Foo
    inline get() = Foo()

var bar: Bar
    get() = ...
    inline set(v) { ... }
Run Code Online (Sandbox Code Playgroud)

kotlin

10
推荐指数
1
解决办法
1480
查看次数

为什么Kotlin需要函数引用语法?

Kotlin docs表示它支持高阶函数.::function当将顶级函数作为参数传递时,为什么语言甚至需要语法?

鉴于:

fun isOdd(x: Int) = x % 2 != 0
val numbers = listOf(1, 2, 3)
println(numbers.filter(::isOdd)) // here.
Run Code Online (Sandbox Code Playgroud)

为什么不呢

fun isOdd(x: Int) = x % 2 != 0
val numbers = listOf(1, 2, 3)
println(numbers.filter(isOdd)) // simple and makes more sense
Run Code Online (Sandbox Code Playgroud)

更多关于函数引用语法的信息.

kotlin

10
推荐指数
2
解决办法
1932
查看次数

如何使用Mockito模拟Spring Boot中的异步(@Async)方法?

@Async使用mockito 模拟asynchronous()方法的最佳方法是什么?提供以下服务:

@Service
@Transactional(readOnly=true)
public class TaskService {
    @Async
    @Transactional(readOnly = false)
    public void createTask(TaskResource taskResource, UUID linkId) {
        // do some heavy task
    }
}
Run Code Online (Sandbox Code Playgroud)

Mockito的验证如下:

@RunWith(SpringRunner.class)
@WebMvcTest(SomeController.class)
public class SomeControllerTest {
    @Autowired
    MockMvc mockMvc;
    @MockBean    
    private TaskService taskService;
    @Rule
    public MockitoRule mockitoRule = MockitoJUnit.rule();

    // other details omitted...

    @Test
    public void shouldVerify() {
        // use mockmvc to fire to some controller which in turn call taskService.createTask
        // .... details omitted
        verify(taskService, times(1)) // taskService is mocked object …
Run Code Online (Sandbox Code Playgroud)

java spring asynchronous mockito spring-boot

7
推荐指数
1
解决办法
2494
查看次数

如何在 Intellij IDEA 运行之前启用 Hibernate 字节码检测?

在 gradle 中你可以使用以下方法来实现:

apply plugin: 'enhance'
buildscript {
    repositories {
        mavenCentral()
    }
    dependencies {
        classpath 'org.hibernate:hibernate-gradle-plugin:VERSION'
    }
}
dependencies {
    compile group: 'org.hibernate.javax.persistence', name: 'hibernate-jpa-[SPEC-VERSION]-api', version: '[IMPL-VERSION]'
    compile group: 'org.hibernate', name: 'hibernate-gradle-plugin', version: 'VERSION'
}
Run Code Online (Sandbox Code Playgroud)

如果我不想通过 Gradle 运行项目,而是想直接通过 Intellij (shift-F10) 运行我的主类,该怎么办?是否也可以在应用程序运行之前执行构建时字节码检测?我应该如何实现这个目标?

java hibernate intellij-idea

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

加载 Typescript 定义文件时应该使用 ES6 导入还是引用路径?

加载 Typescript(以上 1.6)定义文件时是否首选使用 ES6 导入或引用路径注释?

import {describe, it, expect, jasmine} from './jasmine'

或者

import * as jasmine from './jasmine'

///<reference path="jasmine.d.ts"/>

typescript typescript1.6

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