[go: nahoru, domu]

Skip to content

Commit

Permalink
Update Java 11 and 17 instructions
Browse files Browse the repository at this point in the history
  • Loading branch information
scottfrederick committed Oct 13, 2021
1 parent 9fb8031 commit 8dd85f4
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 19 deletions.
42 changes: 26 additions & 16 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,21 +52,6 @@ After installing the 'cf' [command-line interface for Cloud Foundry](http://docs
$ cf push
~~~

By default, gradle will build this app using Java 8 compatibility. If you want to use a more recent version of Java, you will need to update two things. In `build.gradle`, change the Java version in these lines:

~~~
sourceCompatibility = 1.8
targetCompatibility = 1.8
~~~

For example, to use Java 11, you would change the `1.8`. to `1.11`. You will also need to uncomment this line from the README:

~~~
# JBP_CONFIG_OPEN_JDK_JRE: '{ jre: { version: 11.+ } }'
~~~

If you wish to use Java 17, replace `11` with `17` in the above examples.

The application will be pushed using settings in the provided `manifest.yml` file. The output from the command will show the URL that has been assigned to the application.

### Creating and binding services
Expand Down Expand Up @@ -120,4 +105,29 @@ $ cf restart
Database drivers for MySQL, Postgres, Microsoft SQL Server, MongoDB, and Redis are included in the project.

To connect to an Oracle database, you will need to download the appropriate driver (e.g. from http://www.oracle.com/technetwork/database/features/jdbc/index-091264.html). Then make a `libs` directory in the `spring-music` project, and move the driver, `ojdbc7.jar` or `ojdbc8.jar`, into the `libs` directory.
In `build.gradle`, uncomment the line `compile files('libs/ojdbc8.jar')` or `compile files('libs/ojdbc7.jar')` and run `./gradle assemble`
In `build.gradle`, uncomment the line `compile files('libs/ojdbc8.jar')` or `compile files('libs/ojdbc7.jar')` and run `./gradle assemble`.


## Alternate Java versions

By default, the application will be built and deployed using Java 8 compatibility.
If you want to use a more recent version of Java, you will need to update two things.

In `build.gradle`, change the `targetCompatibility` Java version:

~~~
java {
...
targetCompatibility = JavaVersion.VERSION_1_8
}
~~~

Set `targetCompatibility` to `JavaVersion.VERSION_11` for Java 11 or `JavaVersion.VERSION_17` for Java 17.

In `manifest.yml`, uncomment and change the Java buildpack JRE version:

~~~
# JBP_CONFIG_OPEN_JDK_JRE: '{ jre: { version: 11.+ } }'
~~~

Set the version to `11.+` for Java 11 or `17.+` for Java 17.
13 changes: 10 additions & 3 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,6 @@ apply plugin: 'io.spring.dependency-management'

version = '1.0'

sourceCompatibility = 1.8
targetCompatibility = 1.8

repositories {
mavenCentral()
}
Expand Down Expand Up @@ -69,6 +66,16 @@ dependencies {
testImplementation "org.springframework.boot:spring-boot-starter-test"
}

java {
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8

if (JavaVersion.current() != project.targetCompatibility) {
logger.warn("The build is using Java ${JavaVersion.current()} to build a Java ${project.targetCompatibility} compatible archive.")
logger.warn("See the project README for instructions on changing the target Java version.")
}
}

jar {
archiveBaseName = "spring-music"
}

0 comments on commit 8dd85f4

Please sign in to comment.