我已經設置Amazon AWS EC2實例並安裝了tomcat8和jdk 1.8。 我在我的tomcat的webapps目錄中部署了基於Spring/Hibernate的web-app war文件,到目前爲止一切正常。它的Spring Web MVC。在亞馬遜設置spring活動配置文件AWS EC2實例
但我想實現spring.active.profiles與我從未工作的現有配置。
下面是我的JPAConfig文件內容,它在本地服務器上運行良好,但不在AWS EC2。我覺得我的EC2實例存在一些錯誤配置。
@Configuration
@EnableTransactionManagement
@PropertySources({
@PropertySource("classpath:application.properties"),
@PropertySource("classpath:application-${spring.profiles.active}.properties"),
@PropertySource("classpath:api.properties"),
@PropertySource("classpath:mailer.properties") })
public class JPAConfiguration {
@Autowired
private Environment environment;
//rest or codes
如果我評論@PropertySource("classpath:application-${spring.profiles.active}.properties"),
線接工作的事情在EC2上不錯,但它拿起出於顯而易見的原因application.properties
文件內容。當我取消註釋時,我的EC2網址返回404找不到。
請執行spring.active.profiles的EC2實例功能的幫助,使我的EC2實例使用我application-prod.properties
文件
此外,請注意,對於一些未知的原因,我看不到任何其他目錄,除了「
:web應用」在我tomcat8目錄
我假設你使用的是純彈簧,而不是彈簧靴,因爲你沒有提到它。 你如何設置'spring.profiles.active'屬性? –
Spring的web-MVC正在使用 – sumit
在我的本地服務器,使用maven和這個配置' \t \t \t \t org.apache.tomcat.maven \t \t \t \t tomcat7 - Maven的插件 \t \t \t 2,\t 2。2 \t \t \t \t <結構> \t \t \t \t \t /DMS-幅 \t \t \t \t \t \t \t \t \t \t \t \t \t \t \t \t 本地 \t \t \t \t \t systemProperties> \t \t \t \t配置> \t \t \t ' –
sumit