Skip to content

Commit 150acf0

Browse files
final_4_heroku
1 parent 6ee1236 commit 150acf0

7 files changed

Lines changed: 66 additions & 0 deletions

File tree

Procfile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
web: java $JAVA_OPTS -Dspring.profiles.active="datajpa,heroku" -DTOPJAVA_ROOT="." -jar target/dependency/webapp-runner.jar --port $PORT target/*.war

hr.bat

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
call mvn -B -s settings.xml -DskipTests=true clean install
2+
call java -Dspring.profiles.active="datajpa,heroku" -DDATABASE_URL="postgres://user:password@localhost:5432/topjava" -jar target/dependency/webapp-runner.jar target/*.war

pom.xml

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -316,6 +316,36 @@
316316
<activeByDefault>true</activeByDefault>
317317
</activation>
318318
</profile>
319+
<profile>
320+
<id>heroku</id>
321+
<build>
322+
<plugins>
323+
<plugin>
324+
<groupId>org.apache.maven.plugins</groupId>
325+
<artifactId>maven-dependency-plugin</artifactId>
326+
<version>2.10</version>
327+
<executions>
328+
<execution>
329+
<phase>package</phase>
330+
<goals>
331+
<goal>copy</goal>
332+
</goals>
333+
<configuration>
334+
<artifactItems>
335+
<artifactItem>
336+
<groupId>com.github.jsimone</groupId>
337+
<artifactId>webapp-runner</artifactId>
338+
<version>7.0.57.2</version>
339+
<destFileName>webapp-runner.jar</destFileName>
340+
</artifactItem>
341+
</artifactItems>
342+
</configuration>
343+
</execution>
344+
</executions>
345+
</plugin>
346+
</plugins>
347+
</build>
348+
</profile>
319349
</profiles>
320350

321351
<dependencyManagement>

settings.xml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
3+
<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0"
4+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
5+
xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0 http://maven.apache.org/xsd/settings-1.0.0.xsd">
6+
7+
<activeProfiles>
8+
<activeProfile>postgres</activeProfile>
9+
<activeProfile>heroku</activeProfile>
10+
</activeProfiles>
11+
</settings>
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
jpa.showSql=false
2+
hibernate.format_sql=false
3+
hibernate.use_sql_comments=false
4+
database.init=false
5+
jdbc.initLocation=initDB.sql

src/main/resources/spring/spring-db.xml

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,22 @@
6363
</bean>
6464
</beans>
6565

66+
<beans profile="heroku">
67+
<context:property-placeholder location="classpath:/db/heroku.properties" system-properties-mode="OVERRIDE"/>
68+
69+
<bean class="java.net.URI" id="dbUrl">
70+
<constructor-arg value="${DATABASE_URL}"/>
71+
</bean>
72+
<bean id="dataSource"
73+
class="org.apache.tomcat.jdbc.pool.DataSource">
74+
<property name="url" value="#{ 'jdbc:postgresql://' + @dbUrl.getHost() + @dbUrl.getPath() }"/>
75+
<property name="username" value="#{ @dbUrl.getUserInfo().split(':')[0] }"/>
76+
<property name="password" value="#{ @dbUrl.getUserInfo().split(':')[1] }"/>
77+
<property name="driverClassName" value="org.postgresql.Driver"/>
78+
</bean>
79+
</beans>
80+
81+
<!--Repository implementation-->
6682
<beans profile="datajpa,jpa">
6783
<bean id="entityManagerFactory" class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean"
6884
p:dataSource-ref="dataSource"

system.properties

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
java.runtime.version=1.8

0 commit comments

Comments
 (0)