java 带有 Spring 的 JavaMail - 缺少导入
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/12097765/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
JavaMail with Spring - Missing Imports
提问by Sachin
I am getting a
我得到一个
The import cannot be resolved
导入无法解析
error for the following imports,
以下导入的错误,
import org.springframework.mail.MailSender;
import org.springframework.mail.SimpleMailMessage;
I have the following libraries in the classpath, but I not sure which jar file has the above-mentioned imports. Does anybody have any idea?
我在类路径中有以下库,但我不确定哪个 jar 文件具有上述导入。有人有任何想法吗?
org.springframework.aop-3.1.1.RELEASE.jar
org.springframework.asm-3.1.1.RELEASE.jar
org.springframework.beans-3.1.1.RELEASE.jar
org.springframework.context-3.1.1.RELEASE.jar
org.springframework.core-3.1.1.RELEASE.jar
org.springframework.expression-3.1.1.RELEASE.jar
org.springframework.jdbc-3.1.1.RELEASE.jar
org.springframework.orm-3.1.1.RELEASE.jar
org.springframework.web-3.1.1.RELEASE.jar
回答by Reimeus
You are missing org.springframework.context.support-3.1.1.RELEASE.jar
你不见了 org.springframework.context.support-3.1.1.RELEASE.jar
or
或者
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-context-support</artifactId>
<version>3.1.1.RELEASE</version>
</dependency>
if you're using Maven.
如果您使用的是 Maven。
回答by Nicolas Moraes
You should add to pom.xml:
您应该添加到 pom.xml:
<dependency>
<groupId>javax.mail</groupId>
<artifactId>mail</artifactId>
<version>1.4</version>
</dependency>
and
和
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-context-support</artifactId>
<version>4.0.5.RELEASE</version>
</dependency>
$mvn clean install worked for me. :)
$mvn clean install 对我有用。:)
回答by Kevin Crain
You could use a Spring email boot starter dependency for mail, see below:
您可以对邮件使用 Spring 电子邮件启动器依赖项,请参见下文:
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-mail</artifactId>
<version>2.0.1.RELEASE</version>
</dependency>
This will contain both spring-context-support
& javax.mail
dependencies
这将包含spring-context-support
&javax.mail
依赖项
回答by Ripon Al Wasim
org.springframework.context.support-3.x.y.RELEASE.jar is missing. You can download "spring-context-support-3.2.0.RELEASE.jar" from the following URL:
org.springframework.context.support-3.xyRELEASE.jar 丢失。您可以从以下 URL 下载“spring-context-support-3.2.0.RELEASE.jar”:
http://search.maven.org/#search%7Cga%7C1%7Cspring-context-support
http://search.maven.org/#search%7Cga%7C1%7Cspring-context-support
Go to Java Build Path and add as external jar.
转到 Java Build Path 并添加为外部 jar。