Rev 23900 | Rev 23929 | Go to most recent revision | Blame | Compare with Previous | Last modification | View Log | RSS feed
package com.smartdukaan.cron;import java.util.Properties;import org.apache.logging.log4j.LogManager;import org.apache.logging.log4j.Logger;import org.springframework.beans.factory.annotation.Autowired;import org.springframework.boot.ApplicationArguments;import org.springframework.boot.ApplicationRunner;import org.springframework.boot.WebApplicationType;import org.springframework.boot.autoconfigure.SpringBootApplication;import org.springframework.boot.builder.SpringApplicationBuilder;import org.springframework.cache.annotation.EnableCaching;import org.springframework.context.annotation.Bean;import org.springframework.context.annotation.ComponentScan;import org.springframework.context.support.PropertySourcesPlaceholderConfigurer;import org.springframework.core.io.ClassPathResource;import org.springframework.mail.javamail.JavaMailSender;import org.springframework.mail.javamail.JavaMailSenderImpl;import org.springframework.scheduling.annotation.EnableScheduling;import com.smartdukaan.cron.migrations.RunOnceTasks;@SpringBootApplication@EnableCaching@EnableScheduling@ComponentScan("com.smartdukaan.cron.*, com.spice.profitmandi.common.*")public class Application implements ApplicationRunner{private static final Logger LOGGER=LogManager.getLogger(Application.class);public static void main(String[] args) throws Throwable {new SpringApplicationBuilder(Application.class).web(WebApplicationType.NONE).run(args);}@Beanpublic static PropertySourcesPlaceholderConfigurer propertyConfigurer1() {LOGGER.info("Called Configuration");PropertySourcesPlaceholderConfigurer propertySourcesPlaceholderConfigurer = new PropertySourcesPlaceholderConfigurer();propertySourcesPlaceholderConfigurer.setLocation(new ClassPathResource("/META-INF/env.properties"));return propertySourcesPlaceholderConfigurer;}@Bean(name="mailSender")public JavaMailSender getGmailSender(){JavaMailSenderImpl mailSender = new JavaMailSenderImpl();//Using gmailmailSender.setHost("smtp.sendgrid.net");mailSender.setPort(587);mailSender.setUsername("shop2020");mailSender.setPassword("U2/=fP,t");Properties javaMailProperties = new Properties();javaMailProperties.put("mail.smtp.starttls.enable", "false");javaMailProperties.put("mail.smtp.auth", "true");javaMailProperties.put("mail.transport.protocol", "smtp");javaMailProperties.put("mail.debug", "true");//Prints out everything on screenmailSender.setJavaMailProperties(javaMailProperties);return mailSender;}@Autowiredprivate RunOnceTasks runOnceTasks;@Overridepublic void run(ApplicationArguments args) throws Exception {LOGGER.info("Called run method");if(args.containsOption("once")) {runOnceTasks.getInvestmentDetails();System.exit(0);}}}