什么:范围“提供”是什么意思?

时间:2016-09-07 14:29:59

标签: clojure leiningen

我见过很多地方,Clojure项目中的某些依赖项标有:scope "provided"example)。

这是什么意思?

2 个答案:

答案 0 :(得分:3)

你可以阅读maven范围,因为它是一样的。 Difference between maven scope compile and provided for JAR packaging。所以据我所知,如果你在项目中使用这个lib,你也应该将这些依赖项与lib本身一起添加到你的project.clj中(我仍然可以弄错)

您还可以使用其他一些范围:https://maven.apache.org/guides/introduction/introduction-to-dependency-mechanism.html#Dependency_Scope

答案 1 :(得分:2)

这基本上是一个maven概念。 package model; import java.util.Date; import javax.persistence.Column; import javax.persistence.Entity; import javax.persistence.GeneratedValue; import javax.persistence.GenerationType; import javax.persistence.Id; import javax.persistence.Table; import javax.persistence.Temporal; import javax.persistence.TemporalType; import javax.persistence.PrePersist; @Entity @Table(name="status_update") public class StatusUpdate { @Id @Column(name="id") @GeneratedValue(strategy=GenerationType.AUTO) private Long id; @Column(name="text") private String text; @Column(name="added") @Temporal(TemporalType.TIMESTAMP) private Date added; @PrePersist protected void onCreate() { if (added == null) { added = new Date(); } } public StatusUpdate(String text) { this.text = text; } public StatusUpdate(String text, Date added) { this.text = text; this.added = added; } public Long getId() { return id; } public void setId(Long id) { this.id = id; } public String getText() { return text; } public void setText(String text) { this.text = text; } public Date getAdded() { return added; } public void setAdded(Date added) { this.added = added; } @Override public int hashCode() { final int prime = 31; int result = 1; result = prime * result + ((added == null) ? 0 : added.hashCode()); result = prime * result + ((id == null) ? 0 : id.hashCode()); result = prime * result + ((text == null) ? 0 : text.hashCode()); return result; } @Override public boolean equals(Object obj) { if (this == obj) return true; if (obj == null) return false; if (getClass() != obj.getClass()) return false; StatusUpdate other = (StatusUpdate) obj; if (added == null) { if (other.added != null) return false; } else if (!added.equals(other.added)) return false; if (id == null) { if (other.id != null) return false; } else if (!id.equals(other.id)) return false; if (text == null) { if (other.text != null) return false; } else if (!text.equals(other.text)) return false; return true; } } 表示已经为环境打包(或“提供”)给定的依赖项。 jar是编译所必需的,但它不会与应用程序一起打包。这些也不是传递依赖。

要了解有关传递依赖的更多信息,请参阅here