我刚将我的项目从Windows移动到Ubuntu。在Windows上程序运行正常,但我在Ubuntu中收到此错误:
无法找到Org.springframework.mail.javamail.JavaMailSender类型的Bean
以下是代码以及我如何使用它。并且它在Windows上不使用Ubuntu并且收到此错误
@Autowired
private JavaMailSender mailSender;
User user = userService.findByUsername(principal.getName());
Order order = orderService.createOrder(shoppingCart, shippingAddress, billingAddress, payment, shippingMethod, user);
mailSender.send(mailConstructor.constructOrderConfirmationEmail(user, order, Locale.ENGLISH));
shoppingCartService.clearShoppingCart(shoppingCart);
LocalDate today = LocalDate.now();
LocalDate estimatedDeliveryDate;
***************************
APPLICATION FAILED TO START
***************************
Description:
Field mailSender in com.bookstore.controller.CheckoutController required a bean of type 'org.springframework.mail.javamail.JavaMailSender' that could not be found.
- Bean method 'mailSender' not loaded because AnyNestedCondition 0 matched 2 did not; NestedCondition on MailSenderAutoConfiguration.MailSenderCondition.JndiNameProperty @ConditionalOnProperty (spring.mail.jndi-name) did not find property 'jndi-name'; NestedCondition on MailSenderAutoConfiguration.MailSenderCondition.HostProperty @ConditionalOnProperty (spring.mail.host) did not find property 'host'
Action:
Consider revisiting the conditions above or defining a bean of type 'org.springframework.mail.javamail.JavaMailSender' in your configuration.
我认为它与防病毒有关,在windows中我不得不反病毒而Ubuntu我该怎么办?
答案 0 :(得分:1)
您是否迁移了application.properties?
由于@ConditionalOnProperty注释,未加载bean。它期望首先初始化其他bean / proprties,它由application.properties
中的值控制