我正在设计一个RESTful API,我想出了一个与子资源相关的问题.
我看到其他API使用完整的URL来操作子资源.就拿例子Company has Departments
和Department has Employees
.
在开始我虽然关于实现所有可能的URL.导致以下结果:
方法A.
01. ### COMPANY URLS ###
02. DELETE /companies/{companyId}
03. GET /companies/{companyId}
04. POST /companies
05. PUT /companies/{companyId}
06.
07. ### DEPARTMENT URLS ###
08. DELETE /companies/{companyId}/departments/{departmentId}
09. GET /companies/{companyId}/departments/{departmentId}
10. POST /companies/{companyId}/departments
11. PUT /companies/{companyId}/departments/{departmentId}
12. DELETE /departments/{departmentId}
13. GET /departments/{departmentId}
14. PUT /departments/{departmentId}
15.
16. ### EMPLOYEE URLS ###
17. DELETE /companies/{companyId}/departments/{departmentId}/employees/{employeeId}
18. GET /companies/{companyId}/departments/{departmentId}/employees/{employeeId}
19. POST /companies/{companyId}/departments/{departmentId}/employees
20. PUT /companies/{companyId}/departments/{departmentId}/employees/{employeeId}
21. DELETE /departments/{departmentId}/employees/{employeeId}
22. GET …
Run Code Online (Sandbox Code Playgroud) 我的目标:使用普通/文本,文本/ html和附件通过SMTP发送交易电子邮件.
我的代码:用JavaMail实现
我的问题:它在hotmail或outlook上看起来很好.但是在gmail上,如果它是带有.txt附件的电子邮件,它就不会正确显示邮件正文(如果附件是图像,它可以正常工作)
任何帮助将受到高度赞赏.
这是我的原始SMTP输出:
Subject: ALTERNATIVE | TXT | HTML |ATT.ATTACHMENT | Thu Jun 13 17:48:04 EDT
2013
MIME-Version: 1.0
Content-Type: multipart/alternative;
boundary="----=_Part_0_21791733.1371160084561"
------=_Part_0_21791733.1371160084561
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
Body message in text format!
------=_Part_0_21791733.1371160084561
Content-Type: text/html; charset=us-ascii
Content-Transfer-Encoding: 7bit
Body message in <b>html</b> format! Sent on Thu Jun 13 17:48:04 EDT 2013<br> to: me@gmail.com<br> to: me@mijo.com<br> cc: me@hotmail.com<br> cc: rafael.santos.test@hotmail.com
------=_Part_0_21791733.1371160084561
Content-Type: text/plain; charset=us-ascii; name=email_attachment.txt
Content-Transfer-Encoding: 7bit
Content-Disposition: attachment; filename=email_attachment.txt
This is …
Run Code Online (Sandbox Code Playgroud) 假设我有一个为RFC 3339格式化的字符串日期,例如由以下代码生成的"2013-07-04T23:37:46.782Z":
// This is our date/time
Date nowDate = new Date();
// Apply RFC3339 format using JODA-TIME
DateTime dateTime = new DateTime(nowDate.getTime(), DateTimeZone.UTC);
DateTimeFormatter dateFormatter = ISODateTimeFormat.dateTime();
String dateString = dateFormatter.print(dateTime);
System.out.println("Server side date (RFC 3339): " + dateString );
// Server side date (RFC 3339): 2013-07-04T23:37:46.782Z
Run Code Online (Sandbox Code Playgroud)
现在我想使用JODA-TIME从我的字符串"2013-07-04T23:37:46.782Z"创建一个java.util.Date.我如何实现这一目标?
我有一个带有测试类的Maven项目,该类src/test/java/MyDevClass
仅用于开发/测试目的。我想在命令行启动spring-boot-maven-plugin时使用它mvn spring-boot:run
。
因此,我pom.xml
包含:
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<configuration>
<!-- TODO: Will create a maven profile and have useTestClasspath only for development/testing -->
<useTestClasspath>true</useTestClasspath>
</configuration>
</plugin>
</plugins>
</build>
Run Code Online (Sandbox Code Playgroud)
但是,出现以下错误:
org.springframework.beans.factory.CannotLoadBeanClassException: Cannot find class [MyDevClass]
Caused by: java.lang.ClassNotFoundException: MyDevClass
Run Code Online (Sandbox Code Playgroud)
足够有趣的是,我还有另一个使用tomcat7-maven-plugin的项目,并且工作正常:
<plugin>
<groupId>org.apache.tomcat.maven</groupId>
<artifactId>tomcat7-maven-plugin</artifactId>
<version>2.0</version>
<configuration>
<useTestClasspath>true</useTestClasspath>
</configuration>
</plugin>
Run Code Online (Sandbox Code Playgroud)
我缺少什么?
email ×1
html-email ×1
jakarta-mail ×1
java ×1
jodatime ×1
maven-plugin ×1
rest ×1
restful-url ×1
smtp ×1
spring-boot ×1