“java.lang.NoClassDefFoundError:org / springframework / core / type / AnnotatedTypeMetadata”

时间:2013-11-16 12:33:54

标签: spring-mvc javamail

@Bean
    public JavaMailSender mailSender() {
        JavaMailSenderImpl mailSender = new JavaMailSenderImpl();
        mailSender.setDefaultEncoding("UTF-8");
        mailSender.setHost("smtp.googlemail.com");
        mailSender.setPort(465);
        mailSender.setUsername("XXXXXXXXX@gmail.com");
        mailSender.setPassword("XXXXXXXXXXXXXXX");
        Properties properties = new Properties();
        properties.put("mail.smtp.auth", true);
        properties.put("mail.smtp.starttls.enable", true);
        mailSender.setJavaMailProperties(properties);
        return mailSender;
    }

我正在尝试使用javamailsender发送邮件,因为我使用注释配置了上述代码,之后我得到了“java.lang.NoClassDefFoundError: org/springframework/core/type/AnnotatedTypeMetadata”异常任何建议。

2 个答案:

答案 0 :(得分:7)

似乎缺少依赖spring-core。您应该添加此jar

答案 1 :(得分:2)

或者使用maven从这里选择依赖项:http://mvnrepository.com/artifact/org.springframework/spring-core

<dependency>
    <groupId>org.springframework</groupId>
    <artifactId>spring-core</artifactId>
    <version>4.0.6.RELEASE</version>
 </dependency>