当前位置:   article > 正文

idea maven创建kotlin项目

idea maven创建kotlin项目

第一步:打开idea

第二步:添加依赖

  1. <repositories>
  2. <repository>
  3. <id>mavenCentral</id>
  4. <url>https://repo1.maven.org/maven2/</url>
  5. </repository>
  6. </repositories>
  7. <build>
  8. <sourceDirectory>src/main/kotlin</sourceDirectory>
  9. <testSourceDirectory>src/test/kotlin</testSourceDirectory>
  10. <plugins>
  11. <plugin>
  12. <groupId>org.jetbrains.kotlin</groupId>
  13. <artifactId>kotlin-maven-plugin</artifactId>
  14. <version>1.9.21</version>
  15. <executions>
  16. <execution>
  17. <id>compile</id>
  18. <phase>compile</phase>
  19. <goals>
  20. <goal>compile</goal>
  21. </goals>
  22. </execution>
  23. <execution>
  24. <id>test-compile</id>
  25. <phase>test-compile</phase>
  26. <goals>
  27. <goal>test-compile</goal>
  28. </goals>
  29. </execution>
  30. </executions>
  31. </plugin>
  32. <plugin>
  33. <artifactId>maven-surefire-plugin</artifactId>
  34. <version>2.22.2</version>
  35. </plugin>
  36. <plugin>
  37. <artifactId>maven-failsafe-plugin</artifactId>
  38. <version>2.22.2</version>
  39. </plugin>
  40. <plugin>
  41. <groupId>org.codehaus.mojo</groupId>
  42. <artifactId>exec-maven-plugin</artifactId>
  43. <version>1.6.0</version>
  44. <configuration>
  45. <mainClass>MainKt</mainClass>
  46. </configuration>
  47. </plugin>
  48. </plugins>
  49. </build>
  50. <dependencies>
  51. <dependency>
  52. <groupId>org.jetbrains.kotlin</groupId>
  53. <artifactId>kotlin-test-junit5</artifactId>
  54. <version>1.9.21</version>
  55. <scope>test</scope>
  56. </dependency>
  57. <dependency>
  58. <groupId>org.junit.jupiter</groupId>
  59. <artifactId>junit-jupiter-engine</artifactId>
  60. <version>5.10.0</version>
  61. <scope>test</scope>
  62. </dependency>
  63. <dependency>
  64. <groupId>org.jetbrains.kotlin</groupId>
  65. <artifactId>kotlin-stdlib</artifactId>
  66. <version>1.9.21</version>
  67. </dependency>
  68. </dependencies>

它自己会下载所需依赖,依赖位置:C:\Users\Administrator\.m2\repository\org\jetbrains

下载速度会很慢,咱们要不换个镜像或者挂t都行

第三步:运行示例代码

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/羊村懒王/article/detail/135796
推荐阅读
相关标签
  

闽ICP备14008679号