После указания настроек, можете сразу запустить приложение, чтобы убедиться, что вы правильно указали настройки для подключения БД.
2. Установка git и heroku
Заходим на сайт https://git-scm.com/, скачиваем последнюю версию установщик и устанавливаем Git.
Заходим в командную строку и настраиваем имя и почту разработчика
Microsoft Windows [Version 10.0.18362.476](c) Корпорация Майкрософт (Microsoft Corporation), 2019. Все права защищены.C:\Users\nickg>git config --global user.name "Mykola Hodovychenko"C:\Users\nickg>git config --global user.email hodovychenko@opu.uaC:\Users\nickg>git config --listhttp.sslcainfo=C:/Program Files/Git/mingw64/ssl/certs/ca-bundle.crthttp.sslbackend=openssldiff.astextplain.textconv=astextplaincore.autocrlf=truecore.fscache=truecore.symlinks=falsecore.editor="C:\\Program Files\\Notepad++\\notepad++.exe" -multiInst -notabbar -nosession -noPlugincredential.helper=manageruser.name=Mykola Hodovychenkouser.email=hodovychenko@opu.uagui.recentrepo=E:/spring/testproject3C:\Users\nickg>
Возвращаемся в Heroku, скачиваем и настраиваем Heroku CLI
Заходим в командую строку и логинимся на heroku с помощью команды heroku login
C:\Users\nickg>heroku loginheroku:Press any key to open up the browser to login or q to exit:Opening browser to https://cli-auth.heroku.com/auth/browser/630e1a02-f90e-4217-8170-cd71d7fc700eLogging in... doneLogged in as hodovychenko@opu.ua
Переходим в директорию проекта, после чего инициализируем git-репозиторий с помощью команды git init
C:\Users\nickg>cd d:\springdemo\ejod:\springdemo\ejo>git initInitialized empty Git repository in d:/springdemo/ejo/.git/
Далее устанавливаем удаленный репозиторий
d:\springdemo\ejo>heroku git:remote -a opnu-ejset git remote heroku to https://git.heroku.com/opnu-ej.git
Начинаем отслеживать файлы проекта с помощью команды git add ., после чего делаем коммит с помощью команды git commit -am "initial commit".
d:\springdemo\ejo>git add .warning:LF will be replaced by CRLF in .gitignore.The file will have its original line endings in your working directorywarning:LF will be replaced by CRLF in .mvn/wrapper/MavenWrapperDownloader.java.The file will have its original line endings in your working directorywarning:LF will be replaced by CRLF in .mvn/wrapper/maven-wrapper.properties.The file will have its original line endings in your working directorywarning:LF will be replaced by CRLF in mvnw.The file will have its original line endings in your working directorywarning:LF will be replaced by CRLF in mvnw.cmd.The file will have its original line endings in your working directorywarning:LF will be replaced by CRLF in pom.xml.The file will have its original line endings in your working directorywarning:LF will be replaced by CRLF in src/main/java/com/example/ejo/EjoApplication.java.The file will have its original line endings in your working directorywarning:LF will be replaced by CRLF in src/test/java/com/example/ejo/EjoApplicationTests.java.The file will have its original line endings in your working directoryd:\springdemo\ejo>git commit -am "initial commit"[master (root-commit) 162bc53] initial commit16 files changed, 886 insertions(+)create mode 100644 .gitignorecreate mode 100644 .mvn/wrapper/MavenWrapperDownloader.javacreate mode 100644 .mvn/wrapper/maven-wrapper.jarcreate mode 100644 .mvn/wrapper/maven-wrapper.propertiescreate mode 100644 mvnwcreate mode 100644 mvnw.cmdcreate mode 100644 pom.xmlcreate mode 100644 src/main/java/com/example/ejo/Controller.javacreate mode 100644 src/main/java/com/example/ejo/EjoApplication.javacreate mode 100644 src/main/java/com/example/ejo/Group.javacreate mode 100644 src/main/java/com/example/ejo/GroupRepository.javacreate mode 100644 src/main/java/com/example/ejo/Service.javacreate mode 100644 src/main/java/com/example/ejo/Student.javacreate mode 100644 src/main/java/com/example/ejo/StudentRepository.javacreate mode 100644 src/main/resources/application.ymlcreate mode 100644 src/test/java/com/example/ejo/EjoApplicationTests.java
Теперь можно пушить проект на удаленный репозиторий с помощью команды git push heroku master.
d:\springdemo\ejo>git push heroku masterEnumerating objects:32, done.Counting objects:100% (32/32), done.Delta compression using up to 6 threadsCompressing objects:100% (23/23), done.Writing objects:100% (32/32), 54.39 KiB | 9.06 MiB/s, done.Total 32 (delta 1), reused 0 (delta 0)remote:Compressing source files... done.remote:Building source:remote:remote:-----> Java app detectedremote:-----> Installing JDK 1.8... doneremote:-----> Executing:./mvnw -DskipTests clean dependency:list installremote: [INFO] Scanning for projects......remote: [INFO] Replacing main artifact with repackaged archiveremote: [INFO]remote: [INFO] --- maven-install-plugin:2.5.2:install (default-install) @ ejo ---remote: [INFO] Downloading from central: https://repo.maven.apache.org/maven2/org/apache/maven/shared/maven-shared-utils/0.4/maven-shared-utils-0.4.pom
remote: [INFO] Downloaded from central: https://repo.maven.apache.org/maven2/org/apache/maven/shared/maven-shared-utils/0.4/maven-shared-utils-0.4.pom (4.0 kB at 450 kB/s)
remote: [INFO] Downloading from central: https://repo.maven.apache.org/maven2/classworlds/classworlds/1.1-alpha-2/classworlds-1.1-alpha-2.jar
remote: [INFO] Downloading from central: https://repo.maven.apache.org/maven2/org/apache/maven/shared/maven-shared-utils/0.4/maven-shared-utils-0.4.jar
remote: [INFO] Downloaded from central: https://repo.maven.apache.org/maven2/classworlds/classworlds/1.1-alpha-2/classworlds-1.1-alpha-2.jar (38 kB at 1.1 MB/s)
remote: [INFO] Downloading from central: https://repo.maven.apache.org/maven2/org/codehaus/plexus/plexus-utils/3.0.15/plexus-utils-3.0.15.jar
remote: [INFO] Downloaded from central: https://repo.maven.apache.org/maven2/org/apache/maven/shared/maven-shared-utils/0.4/maven-shared-utils-0.4.jar (155 kB at 2.0 MB/s)
remote: [INFO] Downloaded from central: https://repo.maven.apache.org/maven2/org/codehaus/plexus/plexus-utils/3.0.15/plexus-utils-3.0.15.jar (239 kB at 3.0 MB/s)
remote: [INFO] Installing /tmp/build_bee447e74484e663663b1d166f8e9456/target/ejo-0.0.1-SNAPSHOT.jar to /app/tmp/cache/.m2/repository/com/example/ejo/0.0.1-SNAPSHOT/ejo-0.0.1-SNAPSHOT.jar
remote: [INFO] Installing /tmp/build_bee447e74484e663663b1d166f8e9456/pom.xml to /app/tmp/cache/.m2/repository/com/example/ejo/0.0.1-SNAPSHOT/ejo-0.0.1-SNAPSHOT.pom
remote: [INFO] ------------------------------------------------------------------------remote: [INFO] BUILD SUCCESSremote: [INFO] ------------------------------------------------------------------------remote: [INFO] Total time:20.474 sremote: [INFO] Finished at: 2019-11-26T21:46:52Zremote: [INFO] ------------------------------------------------------------------------remote:-----> Discovering process typesremote:Procfile declares types -> (none)remote:Default types for buildpack -> webremote:remote:-----> Compressing...remote:Done:84.1Mremote:-----> Launching...remote:Released v5remote:https://opnu-ej.herokuapp.com/ deployed to Herokuremote:remote:Verifying deploy... done.To https://git.heroku.com/opnu-ej.git * [new branch] master -> masterd:\springdemo\ejo>
Как видим, мы успешно развернули проект на Heroku. Проверим работу веб-сервиса. Перейдем в браузер и укажем адрес https://opnu-ej.herokuapp.com/
Теперь попробуем осуществить REST-запросы к серверу. Добавим группу, добавим студента, получим список групп.