web上到处都是Java Code示例。但是属性文件内容AwsCredentials.properties
的示例在哪里?
public AmazonSESMailer(Environment env) throws IOException {
this.env = env;
InputStream resource = AmazonSESMailer.class
.getResourceAsStream("/AwsCredentials.properties");
PropertiesCredentials credentials = new PropertiesCredentials(resource);
this.client = new AmazonSimpleEmailServiceClient(credentials);
Properties props = new Properties();
props.setProperty("mail.transport.protocol", "aws");
props.setProperty("mail.aws.user", credentials.getAWSAccessKeyId());
props.setProperty("mail.aws.password", credentials.getAWSSecretKey());
this.session = Session.getInstance(props);
}
private final static Logger logger = LoggerFactory
.getLogger(AmazonSESMailer.class);
private final static String FROM = "vraptor.simplemail.main.from";
private final static String REPLY_TO = "vraptor.simplemail.main.replyTo";
private final static String SEND_REAL_EMAIL = "vraptor.simplemail.send_real_email";
getResourceAsStream("/awscredals .properties")文件是由类加载器加载的,所以把它放在web应用的"classes"文件夹中。然后文件的内容应该只有两行:
accessKey = UTZA…secretKey = Alj…
享受