Tag: intellij idea

如何获得IntelliJ IDEA代码完成作为Kotlin顶级函数导入静态Java方法?

在编辑Kotlin代码时,IntelliJ IDEA代码完成提示了静态Java方法,但是它导入了Java类而不是静态方法作为顶级函数(请参阅函数作用域 )。 例如键入“chrome”并按Enter将import org.openqa.selenium.remote.DesiredCapabilities并将“chrome”替换为“DesiredCapabilities.chrome()”,而不是添加import org.openqa.selenium.remote.DesiredCapabilities.chrome并将“铬“作为”铬“。 如何获得IntelliJ IDEA代码完成作为顶级函数导入静态Java方法?

有没有办法使用Gradle将Kotlin类编译为JavaScript?

我正在使用Kotlin Gradle插件构建一个项目。 一般来说,我的目标是JVM,但将项目的一部分编译为JavaScript将会非常有用。 我知道在使用IntellJ插件构建项目时(如在浏览器博客文章中写入Kotlin中所述 ),项目可能会定位JavaScript,但是如何使用Gradle来实现呢? 把项目分成几个gradle模块,我很确定。

更改Corda中的默认h2Port

我可以使用这个默认的jdbc:h2:tcp://10.0.1.6:53062 /节点连接到h2数据库。 我想将其更改为自定义为50002.所以我添加了build.gradle文件中的端口,并启动使用customOverrides在主文件中的节点。 build.gradle文件: node { name “O=PartyA,L=London,C=GB” advertisedServices = [] p2pPort 10108 rpcPort 10109 webPort 10110 h2Port 50002 cordapps = [ “com.template:states-and-contracts:$version”, “com.template:other-sources:$version”, “net.corda:corda-finance:$corda_release_version” ] rpcUsers = [[ user: “user1”, “password”: “test”, “permissions”: [“ALL”]]] } 主文件: startNode(providedName = CordaX500Name(“PartyA”, “London”, “GB”), rpcUsers = listOf(user),customOverrides = mapOf(“h2Port” to 50002)) 但仍然它不能连接到50002.建立这个是配置文件结构。 node.conf文件: h2port=50002 myLegalName=”O=PartyA,L=New York,C=US” networkMapService […]

JavaCodeStyleManager.getInstance(project).shortenClassReferences()不起作用

我不能使用JavaCodeStyleManager.getInstance(project).shortenClassReferences(); 使其添加导入语句。 在sourceText有完整的资格类名字符串像这样.. “@ com.google.gson.annotations.Expose \ n@com.google.gson.annotations.SerializedName(\”“+ jsonKey +”\“)” public void generateFiles(PsiDirectory directory, List classDataList) { final Project project = directory.getProject(); WriteCommandAction.runWriteCommandAction(directory.getProject(), (Runnable) () -> { PsiFileFactory factory = PsiFileFactory.getInstance(project); PsiDirectoryFactory directoryFactory = PsiDirectoryFactory.getInstance(directory.getProject()); JavaCodeStyleManager manager = JavaCodeStyleManager.getInstance(project); for (ClassModel classData : classDataList) { classData.packageName = directoryFactory.getQualifiedName(directory, true); String sourceText = generateFileContentForClass(classData); PsiFile classFile = […]

在Intellij中编译java 9问题

我正在尝试在最新的intellij(社区版)中使用Java9进行游戏: IntelliJ IDEA 2016.3 Build#IC-163.7743.44,构建于2016年11月17日JRE:1.8.0_112-release-408-b2 x86 JVM:由JetBrains sro开发的OpenJDK Server VM 不写任何代码Error:Abnormal build process termination: C:\Users\pisarevv\Desktop\jdk-9\bin\java -Xmx700m -Djava.awt.headless=true -Djdt.compiler.useSingleThread=true -Dcompile.parallel=false -Drebuild.on.dependency.change=true -Djava.net.preferIPv4Stack=true -Dio.netty.initialSeedUniquifier=1630946162877517857 -Dfile.encoding=windows-1252 -Djps.file.types.component.name=CommunityFileTypes -Duser.language=en -Duser.country=US -Didea.paths.selector=IdeaIC2016.3 “-Didea.home.path=C:\Program Files (x86)\JetBrains\IntelliJ IDEA Community Edition 2016.3” -Didea.config.path=C:\Users\pisarevv\.IdeaIC2016.3\config -Didea.plugins.path=C:\Users\pisarevv\.IdeaIC2016.3\config\plugins -Djps.log.dir=C:/Users/pisarevv/.IdeaIC2016.3/system/log/build-log “-Djps.fallback.jdk.home=C:/Program Files (x86)/JetBrains/IntelliJ IDEA Community Edition 2016.3/jre/jre” -Djps.fallback.jdk.version=1.8.0_112-release -Djava.io.tmpdir=C:/Users/pisarevv/.IdeaIC2016.3/system/compile-server/_temp_ -Dkotlin.incremental.compilation.experimental=true -Dkotlin.daemon.enabled -Dkotlin.daemon.client.alive.path=\”C:\Users\pisarevv\AppData\Local\Temp\kotlin-idea-451096579120734544-is-running\” -classpath “C:/Program Files (x86)/JetBrains/IntelliJ IDEA Community […]

我可以使用lambda的名称作为“括号外”传递的参数吗?

我可以在括号外写一个lambdaexpression式,但是我不能把它放在名字旁边。 我尝试了很多方法: val plus3: (Int,Int,Int)->Int = {a,b,c->a+b+c} println(apply3(1,2,3){a,b,c->a+b+c}) // OK println(apply3(1,2,3){plus3}) // Type mismatch. Required: Int, Found: (Int,Int,Int)->Int println(apply3(1,2,3){(plus3)}) // Type mismatch. Required: Int, Found: (Int,Int,Int)->Int println(apply3(1,2,3)plus3) // unresolved reference println(apply3(1,2,3){plus3()}) // value captured in a closure println(apply3(1,2,3){(plus3)()}) // value captured in a closure 在那里放置一个名字的语法是什么(在括号之外)? 我不知道为什么,但在文档中没有关于主题的文字。 它说,我们可以把lambda放在那里,但不是关于表示lambda的variables或常量。

Spring Boot无法在IntelliJ中运行单个测试

最近开始发生,但我不确定是什么改变了。 当我从IntelliJ运行所有测试时,一切都很好。 而且gradle build也很好。 当我运行一个unit testing时,一切都很好。 当我运行一个Web集成测试时,它失败,因为一个配置类具有所有的空属性。 配置类看起来像(Kotlin): @Component @ConfigurationProperties(prefix = “api”) public open class ApiConfigImpl : ApiConfig { 一个测试看起来像: @RunWith(SpringJUnit4ClassRunner::class) @ContextConfiguration(classes = arrayOf(ApplicationAssembly::class), loader = SpringApplicationContextLoader::class) @WebIntegrationTest open class CandidateProfileControllerTest { @Inject lateinit var profileRepo: CandidateProfileRepository //etc a few more deps used to setup test data @Test open fun getById() { val greg = […]

exception:java.lang.ClassNotFoundException:org.reactivestreams.Publisher

在IntelliJ IDEA 2017.1.2(Build#IC-171.4249.39)中使用RxJava和Kotlin开发的基于JavaFX Gradle的应用程序中,出现exception: 线程“JavaFX Application Thread”中的exceptionjava.lang.NoClassDefFoundError:org / reactivestreams / Publisher 每次这样的代码 return Completable.complete() 被执行。 在类似问题的建议之后为什么我得到NoClassDefFoundError:org / reactivestreams / Publisher ,我试图添加包括反应流到我的build.gradle脚本的dependencies块 dependencies { compile ‘org.jetbrains.kotlin:kotlin-stdlib:1.1.2’ compile ‘org.reactivestreams:reactive-streams:1.0.0’ compile ‘io.reactivex.rxjava2:rxkotlin:2.0.0’ } 但问题依然存在。 依赖关系树看起来像这样: compile – Dependencies for source set ‘main’ (deprecated, use ‘implementation ‘ instead). +— org.jetbrains.kotlin:kotlin-stdlib:1.1.2 | \— org.jetbrains:annotations:13.0 +— org.reactivestreams:reactive-streams:1.0.0 \— io.reactivex.rxjava2:rxkotlin:2.0.0 +— io.reactivex.rxjava2:rxjava:2.0.7 […]

在intellij中运行并执行jar时的微妙差异

我正在用尽想法 当我运行在indellij和gradle理念插件应用 ( 应用插件:’想法’ )时,我的春季启动应用程序表现良好。 一旦我从build.gradle中移除插件,它的行为与使用java -jar app.jar执行的应用程序的行为类似 – 下面的描述存在细微但重要的区别。 我有以下情况,由于某些exception,当前tx失败,tx被标记为仅回滚,exception被捕获,并且其处理包括使用TransactionSynchronizationManager.registerSynchronization (new tx)注册后续tx恢复活动。 代码工作正常与思想插件intellij,当我删除插件声明或运行与java -jar注册过程(后tx失败任务)的弹簧启动jar失败,例外: Caused by: java.lang.IllegalStateException: Transaction synchronization is not active at org.springframework.transaction.support.TransactionSynchronizationManager.registerSynchronization(TransactionSynchronizationManager.java:291) ~[spring-tx-4.3.10.RELEASE.jar!/:4.3.10.RELEASE] 顺便说一句,代码是在kotlin,如果它很重要。 有任何想法吗? UPDATE 我觉得有一种竞争条件,因为在调试模式,即使没有理念的插件,应用程序的行为如预期(注册过程成功)。

IntelliJ IDEA使用Gradle构建文件中指定的依赖关系的JavaScript“版本”?

最近(过去几天)这个问题开始发生在我的一台开发机器上。 我正在使用Eclipse的Vert.x的依赖关系为一个Web项目: 的build.gradle dependencies { … // Kotlin compile “org.jetbrains.kotlin:kotlin-stdlib-jre8:$kotlin_version” // Vert.x for web framework compile group: ‘io.vertx’, name: ‘vertx-core’, version: ‘3.4.2’ compile group: ‘io.vertx’, name: ‘vertx-web’, version: ‘3.4.2’ … } 这在过去运行良好 – 我认为触发行动是我升级到IntelliJ 2017.2.2,但现在: IntelliJ无法解析任何-web导入: 如果我检查我的模块的依赖项列表,将显示依赖项的JavaScript版本? 这是怎么发生的 ,我怎样才能确保它被正确识别为Java依赖? 编辑:示例项目可在这里: https : //youtrack.jetbrains.com/issue/IDEA-177950