valik
valik

Reputation: 2094

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

I just moved my project from Windows to Ubuntu. On Windows the program runs fine, but I get this error in Ubuntu:

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

Below is the code and how i have used it . and it works on windows no using Ubuntu and getting this error

 @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.

I think it has to do with anti virus , in windows i had to dis able anti virus but Ubuntu what do i do ?

Upvotes: 2

Views: 3659

Answers (1)

Vinny
Vinny

Reputation: 149

Have you migrated your application.properties?

The bean is not loaded because of @ConditionalOnProperty annotation. It expect other beans/proprties to be initialized first which is governed by values in application.properties

Upvotes: 1

Related Questions