Tag: IntelliJ 想法

Intellij Idea不会编译kotlin,但maven会这样做

我有项目,其中包含基于maven的混合kotlin和java代码。 如果我通过maven(从命令行)编译该项目,那就没关系 [INFO] ———————————————————————— [INFO] BUILD SUCCESS [INFO] ———————————————————————— [INFO] Total time: 30.830 s [INFO] Finished at: 2017-05-19T07:42:55+01:00 [INFO] Final Memory: 44M/482M [INFO] ———————————————————————— Java的: java version “1.8.0_91” Java(TM) SE Runtime Environment (build 1.8.0_91-b14) Java HotSpot(TM) 64-Bit Server VM (build 25.91-b14, mixed mode) 理念: IntelliJ IDEA 2017.1.3 Build #IU-171.4424.56, built on May 12, 2017 JRE: […]

在IntelliJ的Kotlin> Java转换之后,将源代码恢复为Java

所以我想尝试转换我们用Java编写的后端API源代码,并看看它是如何看起来(IIRC转换之前有一个预览),但一旦我做到了,它会自动开始转换所选文件夹中的所有文件,最后它要求代码更正,我回答了没有,因为我想取消它,现在我坚持一个破碎的代码基地没有其他选项比: 恢复到最后的git提交并重新实现从我身边完成的所有更改(我可以阻止它,但在转换之前提交,但是哦) 继续使用Kotlin编码,但我有代码错误,我不知道如何解决 我所要问的是,如果无论如何要将Kotlin转换回IntelliJ IDEA中的Java? 先谢谢你

Kotlin NoClassDefFoundError和spring @RequestMapping方法

我试图用Kotlin + IntelliJ来学习一些spring的基础知识,而且我遇到了一些麻烦。 @RequestMapping带注释的方法(带参数)会导致exception,而Java等价物完全正常。 Kotlin代码工作正常,但只有没有“processFormTwo”方法(将工作Java代码转换为kotlin也无济于事)。 这里是代码: @Controller class HelloWorldController { @RequestMapping(“/showForm”) fun showForm() = “helloworld-form” // this one works fine @RequestMapping(“/processForm”) fun processForm() = “helloworld” //this one doesn’t @RequestMapping(“/processFormTwo”) fun processFormTwo(request: HttpServletRequest, model: Model): String { var theName = request.getParameter(“studentName”) theName = theName.toUpperCase() val result = “Yo! ” + theName model.addAttribute(“message”, result) return “helloworld” } […]

IntelliJ Idea 2017.3无法启动Kotlin Spring Boot App – @Configuration类可能不是最终的

我能够从IntelliJ 2017.3推出一个春季启动Kotlin应用程序。 在最后一次IntelliJ修复更新后,我无法从IDE启动该应用程序,得到此exception: org.springframework.beans.factory.parsing.BeanDefinitionParsingException: Configuration problem: @Configuration class ‘AccessConfig’ may not be final 我可以像往常一样从终端启动它: java -jar xxxx.jar 这是没有任何意义的,因为我在我的Gradle配置中使用必要的Kotlin Spring插件: buildscript { ext { kotlinVersion = ‘1.2.21’ springBootVersion = ‘2.0.0.RC1’ } repositories { mavenCentral() maven { url “https://repo.spring.io/snapshot” } maven { url “https://repo.spring.io/milestone” } jcenter() maven { url “https://plugins.gradle.org/m2/” } } dependencies { classpath(“org.springframework.boot:spring-boot-gradle-plugin:${springBootVersion}”) classpath(“org.jetbrains.kotlin:kotlin-gradle-plugin:${kotlinVersion}”) classpath(“org.jetbrains.kotlin:kotlin-allopen:${kotlinVersion}”) […]

selenium在Kotlin =>行动不可用

我试图通过在IntelliJ IDEA中使用Kotlin Selenium来点击按钮。 我需要选择表格的前10行,右键单击它们并在上下文菜单中单击一个条目。 因此,我需要一个Actions对象 – 已经在这里的问题开始! “行动”是用红色写的,IntelliJ拒绝导入“org.openqa.selenium.interactions.Actions”它说“未解决的参考:行动”。 但是一定有办法做到这一点! 我越来越绝望,请帮助我! 这是我的测试课: import org.openqa.selenium.By import org.openqa.selenium.WebDriver import org.openqa.selenium.chrome.ChromeDriver import org.testng.annotations.* import java.awt.event.KeyEvent class BatchProcessTest { init{ System.setProperty(“webdriver.chrome.driver”, “C:\\Users\\\chromedriver.exe”) } private val driver = ChromeDriver() as WebDriver private val testBase : TestBase = TestBase(driver) private var isTestClassInitialized = false @BeforeTest private fun initiateTestSuite(){ testBase.startTestObject() testBase.openWebPage() testBase.loginTestUserUsingCredentials(,) testBase.waitForMilliseconds(5000) […]

去create-react-kotlin-app中声明不起作用

我用create-react-kotlin-app ,效果很好。 但是当我用IntelliJ IDEA ULTIMATE打开它时,我注意到go to declaration是行不通的。 但后来我发现检查和建议也不起作用。 其他人是否遇到同样的问题? 有没有办法让它工作?

KotlinJS中的Kootlin失败的世界没有定义

我有一个名为Main.kt的Kotlin文件 package com.ahp.mui fun main(args: Array) { println(“…”) println(“Hello World”) } 项目设置为KotlinJS项目。 一旦我编译,我看到下面的文件正在生成: target/production/ahp-mui/ahp-mui.js target/production/ahp-mui/ahp-mui.js.map target/production/ahp-mui/ahp-mui.meta.js 主生成的文件包含: (function (Kotlin) { ‘use strict’; var _ = Kotlin.defineRootPackage(null, /** @lends _ */ { com: Kotlin.definePackage(null, /** @lends _.com */ { ahp: Kotlin.definePackage(null, /** @lends _.com.ahp */ { mui: Kotlin.definePackage(null, /** @lends _.com.ahp.mui */ { main_kand9s$: function (args) […]

Kotlin Decompiler生成错误的代码 – 是否有可能防止?

class CheckInventory(target: Target) : Command(target) { } 使用IntelliJ的“ 显示Kotlin字节码 ”选项反编译上述Kotlin代码时,它会在super()调用之上继续生成一个语句: class CheckInventory extends Command { public CheckInventory(Target target) { Intrinsic.checkParameterIsNotNull(target, “target”); super(target); //error, must be first call } } 还有其他一些问题,如使用访问修饰符生成顶级类的时候: public class MyClass { } public final class MyClass$WhenMappings { //error, shouldn’t be public } 我检查了Kotlin和IntelliJ更新,我正在使用最新版本。 起初,我认为这可能与编写不好的Kotlin代码有关,但即使是最简单的代码文件似乎也需要某种在Java中非法的检查/生成。 题 有什么方法可以确保反编译过程保持在Java语言规则的范围之内吗?

从命令行运行Java到Kotlin转换器?

您可以使用Intellij和Eclipse的Kotlin插件将Java文件转换为Kotlin。 这个转换是否可以从命令行完成一些如何没有这些IDE?

将任何数据转换为Kotlin中的数组

我正在通过从Kotlin的Map加载数据来初始化一个类。 由于这张地图是直接从JSON收集的,我不确定是否存在任何给定的关键字,或者它的价值是我期望的types。 为了安全地解开这个Map,我正在做以下工作,这看起来很完美: a = rawData[“A”] as? String ?: “” 这些数据中的一部分是进一步嵌套的JSON,我将其解包到数组中; 我试图以同样的方式做到这一点: b = rawData[“B”] as? Array ?: arrayOf() 但是,当我尝试使用数组(如上所述),IntelliJ踢了一个小题大做,说 警告:(111,30)Kotlin:不加限制的演员:任何? 到数组 这只是IDE自身扭曲,还是这种方法真的是不安全的arrays,尽管对于其他types看起来是完全安全的?