try-with-resource is not supported in -source 1.5 error occured when I used try catch in the source

Ben :

This is my pom.xml file. enter image description here
And here is the error message:
enter image description here I want to deploy my java project to heroku. But error occured.

try(Connection connection = dataSource.getConnection()) {

    Statement stmt = connection.createStatement();
    logger.info("Just Beforce sql executed ");
    ResultSet rs = stmt.executeQuery("Select sfid,id, email from salesforce.contact");
    logger.info("ResultSet data " + rs);
    ArrayList<String> output = new ArrayList<String>();
      while (rs.next()) {
        logger.info("ID get Successfully " + rs.getString("id"));
         logger.info("SFID get Successfully " + rs.getString("sfid"));
         logger.info("Email get Successfully " + rs.getString("email"));
       }
 }
 catch (Exception e) {

 }

Apparently, the error is about try(Connection ...), but I just don't understand why it is not allowed. And "is not supported in-source 1.5" confuses me, does it mean java version? or something else?
Any help will be appreciated!!!

Update:I used git to deploy my app, here is my git project link:https://github.com/BenHugh/devcenter-java-quartz

Johan Tidén :

This syntax was implemented in Java 1.7. Heroku thinks that you are writing java 1.5 code. Can you change the project settings so that it understands that you are using (at least) Java 1.7?

Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=389046&siteId=1