Skip to content

Instantly share code, notes, and snippets.

Zoltan Altfatter altfatterz

Block or report user

Report or block altfatterz

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View logs.log
2014-10-25 22:47:22.337 DEBUG 22802 --- [ost-startStop-1] org.hibernate.SQL : drop table page if exists
2014-10-25 22:47:22.337 DEBUG 22802 --- [ost-startStop-1] org.hibernate.SQL : drop table portal if exists
2014-10-25 22:47:22.337 DEBUG 22802 --- [ost-startStop-1] org.hibernate.SQL : create table page (id bigint generated by default as identity, name varchar(255), portal_id bigint, primary key (id))
2014-10-25 22:47:22.341 DEBUG 22802 --- [ost-startStop-1] org.hibernate.SQL : create table portal (id bigint generated by default as identity, name varchar(255), primary key (id))
...
2014-10-25 22:47:23.292 DEBUG 22802 --- [ main] org.hibernate.SQL : insert into portal (id, name) values (null, ?)
2014-10-25 22:47:23.315 DEBUG 22802 --- [ main] org.hibernate.SQL : insert into page (id, name, portal_id) values (null, ?, ?)
2014-10-25 22:47:23.318 DEBUG 22802 --- [ main] org.hibernate.SQL : insert into page (id, name, portal_id) values (null, ?, ?)
2014-10-25 22:47:23.319 DEBUG 22802
View curl-localhost.sh
~ curl http://localhost:8080/pages
{
"_embedded" : {
"pages" : [ {
"name" : "login",
"_links" : {
"self" : {
"href" : "http://localhost:8080/pages/1"
},
"portal" : {
View pom.xml
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-rest</artifactId>
</dependency>
View jboss-setup.sh
SPRING_PROFILES_ACTIVE=jboss ./standalone.sh -c standalone-backbase.xml
View module.xml
<?xml version="1.0" encoding="UTF-8"?>
<module xmlns="urn:jboss:module:1.3" name="com.mysql">
<resources>
<resource-root path="mysql-connector-java-5.1.32.jar"/>
</resources>
<dependencies>
<module name="javax.api"/>
<module name="javax.transaction.api"/>
</dependencies>
</module>
View standalone-backbase.xml
...
<subsystem xmlns="urn:jboss:domain:datasources:2.0">
<datasources>
<datasource jndi-name="java:jboss/datasources/MySQLDataSource" pool-name="MySQLDataSourcePool" enabled="true" use-java-context="true">
<connection-url>jdbc:mysql://localhost/test</connection-url>
<driver>mysql</driver>
</datasource>
<drivers>
<driver name="mysql" module="com.mysql">
<datasource-class>com.mysql.jdbc.Driver</datasource-class>
View PageControllerTest.java
@RunWith(SpringJUnit4ClassRunner.class)
@SpringApplicationConfiguration(classes = Application.class)
@WebAppConfiguration
@IntegrationTest("server.port:0")
public class PageControllerTest {
@Autowired
PageRepository pageRepository;
@Value("${local.server.port}")
View Application.java
@ComponentScan
@EnableAutoConfiguration
public class Application extends SpringBootServletInitializer {
public static void main(String[] args) {
SpringApplication.run(Application.class, args);
}
@Override
protected SpringApplicationBuilder configure(SpringApplicationBuilder application) {
View DatabaseLoader.java
@Service
@Profile("default")
public class DatabaseLoader {
private final PageRepository pageRepository;
private final PortalRepository portalRepository;
@Autowired
public DatabaseLoader(PageRepository pageRepository, PortalRepository portalRepository) {
this.pageRepository = pageRepository;
View application-production.properties
spring.jpa.hibernate.ddl-auto=none
spring.datasource.url=jdbc:mysql://localhost/test
spring.datasource.username=
spring.datasource.password=
You can’t perform that action at this time.