2017-10-09 14 views
1

AWS EC2インスタンスでjarを実行すると、私のスプリングブートアプリケーションがエラーをスローしています。ローカルシステムで実行するとうまく動作します。AWSのmysqlに接続できません

マイapplication.propertiesファイルが

spring.datasource.driver-class-name=com.mysql.jdbc.Driver 
spring.datasource.url=jdbc:mysql://localhost:3306/gbi? useUnicode=true&useJDBCCompliantTimezoneShift=true&useLegacyDatetimeCode=fa lse&serverTimezone=UTC&autoReconnect=true&failOverReadOnly=false&maxReconne cts=10 
spring.jpa.database-platform =org.hibernate.dialect.MySQLDialect 
spring.datasource.username=****** 
spring.datasource.password=******@ 
spring.datasource.pool.size=20 
spring.jpa.hibernate.ddl-auto=update 
server.port=8090 

私はAWSサーバにjarファイルを実行すると、私は続い

Unable to create initial connections of pool. 
com.mysql.jdbc.exceptions.jdbc4.MySQLNonTransientConnectionException: 
Could not create connection to database server. Attempted reconnect 10 
times. Giving up. 
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) 

続く、

Caused by: com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: 
Communications link failure 

The last packet sent successfully to the server was 0 milliseconds ago. 
The driver has not received any packets from the server. 
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native 
Method) 
atsun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62) 
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45) 

次のエラーを取得しています
Caused by: java.net.ConnectException: Connection refused (Connection 
refused) 
at java.net.PlainSocketImpl.socketConnect(Native Method) 
atjava.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:350) 

2017-Oct-09 15:24:49.735 WARN [main] o.s.b.a.o.j.DatabaseLookup - 
Unable to determine jdbc url from datasource 
org.springframework.jdbc.support.MetaDataAccessException: Could not get 
Connection for extracting meta data; nested exception is 
org.springframework.jdbc.CannotGetJdbcConnectionException: Could not get 
JDBC Connection; nested exception is 
com.mysql.jdbc.exceptions.jdbc4.MySQLNonTransientConnectionException: 
Could not create connection to database server. Attempted reconnect 10 
times. Giving up. 

は、どのようにこの問題を解決するために、続きますか?

答えて

0

Ec2にアクセスして[セキュリティグループ]をクリックし、下部にあるMYSQL/Auroraプロトコルの新しいセキュリティグループをTCPとして追加し、ポート番号を選択して、コンピュータのIPアドレスを選択します。 問題を解決できるはずです。

ありがとう、 Madhu

+0

「私のコンピュータのIP」とはどういう意味ですか?私はどこからjarファイルを置くべきでしょうか? –

+0

私はあなたのローカルのアプリケーションだと思ったので、私はあなたのローカルマシンのIPアドレスを置くと言いました。そうでない場合は、セキュリティグループを作成してインバウンドルールに追加します –

関連する問題