有 Java 编程相关的问题?

你可以在下面搜索框中键入要查询的问题!

Org类型的javabean。springframework。邮政javamail。找不到JavaMailSender?

我刚把我的项目从Windows移到Ubuntu。在Windows上,该程序运行正常,但我在Ubuntu中遇到以下错误:

Bean of type Org.springframework.mail.javamail.JavaMailSender could not be found

下面是代码和我如何使用它。它在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我该怎么办


共 (1) 个答案

  1. # 1 楼答案

    你的应用程序迁移了吗。房产

    由于@ConditionalOnProperty注释,bean未加载。它希望其他bean/属性首先被初始化,这由应用程序中的值控制。属性