为什么当IntelliJ run不能正常工作时,我可以使用mvn spring-boot:run启动我的应用程序? [英] Why can I start my application using mvn spring-boot:run while IntelliJ run doen´t work?
问题描述
当我使用命令mvn spring-boot:run时,项目将编译并完美启动.但是,当我在IDE(IntelliJ)中使用播放按钮时,出现以下错误:
When I use the command mvn spring-boot:run the project compiles and starts perfectly. However, when I use the play-button in my IDE (IntelliJ), I get the following error:
Description:
Parameter 3 of constructor in com.example.module.services.PdfService required a bean of type 'org.springframework.mail.javamail.JavaMailSender' that could not be found.
这可能是什么原因?我很想使用IDE提供的调试和开发工具.
What might be the reason for this? I`d love to use the debugging and dev tools provided by the IDE.
我尝试过的事情:
- 选择构建"->重建项目"
- 点击文件>使缓存无效/重新启动
- mvn clean->建立->制作项目
- Maven->重新导入
- 检查首选项" |不存在"中的排除项构建,执行,部署|编译器排除
我的pom.xml
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-mail</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
</dependency>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
发生错误的服务
@Service
public class PdfService {
private final Logger logger = LoggerFactory.getLogger(PdfService.class);
private PdfCreator pdfCreator;
private ConfigProperties properties;
private ReceiptService receiptService;
private JavaMailSender javaMailSender;
private MessageSourceAccessor messageSourceAccessor;
@Autowired
public PdfService(PdfCreator pdfCreator,
ConfigProperties properties,
ReceiptService receiptService,
JavaMailSender javaMailSender,
MessageSourceAccessor messageSourceAccessor) {
this.pdfCreator = pdfCreator;
this.properties = properties;
this.receiptService = receiptService;
this.javaMailSender = javaMailSender;
this.messageSourceAccessor = messageSourceAccessor;
}
非常感谢您的帮助.
推荐答案
您需要添加org.springframework.mail.javamail.JavaMailSender.jar
作为依赖项,因为缺少它.您可以按照以下步骤修复intellij.
You need to add org.springframework.mail.javamail.JavaMailSender.jar
as dependency as it is missing. You may follow the following steps to fix in intellij.
- 下载jar文件.
- 在IntelliJ Idea IDE中,转到文件>项目结构.
- 选择模块.
- 在依存关系"部分中,选择(+)图标>选择JAR或目录
- 将链接粘贴到JAR文件的位置
- 选择确定并应用
现在,它将被修复.
这篇关于为什么当IntelliJ run不能正常工作时,我可以使用mvn spring-boot:run启动我的应用程序?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!