[英]File core.clj is not under a source root error in intellij
I am using IntelliJ IDEA in a Clojure project, I just started but I get the message "File core.clj is not under a source root", the project has 2 folders: .idea
and src
, inside src
I got the core.clj
file in which showing the structure of the project.我在 Clojure 项目中使用 IntelliJ IDEA,我刚开始但收到消息“文件 core.clj 不在源根目录下”,该项目有 2 个文件夹:
.idea
和src
,在src
中我得到了core.clj
显示项目结构的文件。 This is the photo containing the structure of the project.这是包含项目结构的照片。
I have no source root, I just created the core.clj
and the deps.edn
file and the Deps_project.iml
file, nothing else, how can I solve this?我没有源根,我只是创建了
core.clj
和deps.edn
文件以及Deps_project.iml
文件,没有别的,我该如何解决这个问题? Do I need to write another file?我需要写另一个文件吗?
You need just two files for your project:您的项目只需要两个文件:
In file deps.edn
在文件
deps.edn
{:paths ["src"]
:deps {org.clojure/spec.alpha {:mvn/version "0.3.218"}}}
In file src/spec_tutorial/core.clj
在文件
src/spec_tutorial/core.clj
(ns spec-tutorial.core
(:require [clojure.spec.alpha :as s]))
Note there is a correspondence between the Clojure namespace and the source file path, but beware that hyphens -
in namespaces are translated to underscores _
in path names.请注意,Clojure 命名空间与源文件路径之间存在对应关系,但请注意,命名空间中的连字符
-
会转换为路径名中的下划线_
。
Your directory tree should look like so:您的目录树应如下所示:
./deps.edn
./src/spec_tutorial/core.clj
where the ./
prefix is unix-style shorthand for the project directory.其中
./
前缀是项目目录的 unix 风格简写。
So, the ./src
part is determined by the :paths
line in deps.edn
.因此,./src 部分由
./src
中的:paths
行deps.edn
。 The spec_tutorial/core.clj
part is from the namespace spec-tutorial/core
, and the .clj
suffix is the "file-type". spec_tutorial/core.clj
部分来自命名空间spec-tutorial/core
, .clj
后缀是“文件类型”。
Also, note that hyphens in the namespace become underscores in the file/directory names.另请注意,名称空间中的连字符在文件/目录名称中变为下划线。
Another observation: Do not include :test-paths
in the file core.clj
as seen in your screenshot.另一个观察结果:不要在文件
core.clj
中包含:test-paths
,如屏幕截图所示。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.