Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

George hatzigeorgio #14

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 26 additions & 2 deletions usermodel-initial/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,19 @@
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
</dependency>

<dependency>
<groupId>io.rest-assured</groupId>
<artifactId>spring-mock-mvc</artifactId>
<version>3.3.0</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>

<dependency>
<groupId>org.postgresql</groupId>
<artifactId>postgresql</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-devtools</artifactId>
Expand Down Expand Up @@ -98,7 +105,24 @@
</dependencies>

<build>
<finalName>ghatzigeorgio-usermodel</finalName>
<plugins>
<plugin>
<groupId>com.heroku.sdk</groupId>
<artifactId>heroku-maven-plugin</artifactId>
<version>3.0.2</version>
<configuration>
<appName>${project.build.finalName}</appName>
<includeTarget>false</includeTarget>
<includes>
<include>${project.build.directory}/${project.build.finalName}.jar</include>
</includes>
<jdkVersion>${java.version}</jdkVersion>
<processTypes>
<web>java $JAVA_OPTS -Dserver.port=$PORT -jar target/${project.build.finalName}.jar</web>
</processTypes>
</configuration>
</plugin>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
* after the application context has been loaded.
*/
@Transactional
@Component
//@Component
public class SeedData
implements CommandLineRunner
{
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
package com.lambdaschool.usermodel.config;

import com.zaxxer.hikari.HikariConfig;
import com.zaxxer.hikari.HikariDataSource;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.jdbc.DataSourceBuilder;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import javax.sql.DataSource;
@Configuration
public class DataSourceConfig {
@Value("${local.run.db:H2}")
private String dbValue;

@Value("${spring.datasource.url:}")
private String dbURL;

@Bean
public DataSource dataSource() {
if (dbValue.equalsIgnoreCase("POSTGRESQL")) {
//Assume Heroku
HikariConfig config = new HikariConfig();
config.setDriverClassName("org.postgresql.Driver");
config.setJdbcUrl(dbURL);
return new HikariDataSource(config);
} else {
//Assume H2
String URLString = "jbdc:h2:mem:testdb";
String DriverClass = "org.h2.Driver";
String DBUser = "sa";
String DBpass = "";

return DataSourceBuilder.create()
.username(DBUser)
.password(DBpass)
.url(URLString)
.driverClassName(DriverClass)
.build();
}
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.lambdaschool.usermodel.models;

import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;

import javax.persistence.*;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.lambdaschool.usermodel.models;

import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;

import javax.persistence.*;
Expand Down
7 changes: 6 additions & 1 deletion usermodel-initial/src/main/resources/application.properties
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
# Configurations useful for working with H2

local.run.db=POSTGRESQL
spring.h2.console.settings.web-allow-others=true

spring.h2.console.enabled=true
spring.h2.console.path=/h2-console
#
Expand All @@ -17,7 +21,8 @@ spring.jpa.open-in-view=true
# What do with the schema
# drop n create table again, good for testing
spring.jpa.hibernate.ddl-auto=create
spring.datasource.initialization-mode=always
spring.datasource.initialization-mode=never
command.line.runner.enabled=true
#
# Good for production!
# spring.jpa.hibernate.ddl-auto=update
Expand Down
Loading