Started using to Spring
This commit is contained in:
parent
1c60cb6fd5
commit
8062fbee9e
2 changed files with 29 additions and 6 deletions
26
pom.xml
26
pom.xml
|
@ -9,7 +9,6 @@
|
||||||
<plugins>
|
<plugins>
|
||||||
<plugin>
|
<plugin>
|
||||||
<artifactId>maven-compiler-plugin</artifactId>
|
<artifactId>maven-compiler-plugin</artifactId>
|
||||||
<version>3.5.1</version>
|
|
||||||
<configuration>
|
<configuration>
|
||||||
<source>1.8</source>
|
<source>1.8</source>
|
||||||
<target>1.8</target>
|
<target>1.8</target>
|
||||||
|
@ -76,9 +75,34 @@
|
||||||
<artifactId>hibernate-c3p0</artifactId>
|
<artifactId>hibernate-c3p0</artifactId>
|
||||||
<version>5.2.1.Final</version>
|
<version>5.2.1.Final</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
<!-- Spring and Transactions -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.springframework</groupId>
|
||||||
|
<artifactId>spring-context</artifactId>
|
||||||
|
<version>${spring-framework.version}</version>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.springframework</groupId>
|
||||||
|
<artifactId>spring-tx</artifactId>
|
||||||
|
<version>${spring-framework.version}</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<!-- Spring ORM support -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.springframework</groupId>
|
||||||
|
<artifactId>spring-orm</artifactId>
|
||||||
|
<version>${spring-framework.version}</version>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.springframework</groupId>
|
||||||
|
<artifactId>spring-jdbc</artifactId>
|
||||||
|
<version>${spring-framework.version}</version>
|
||||||
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
<properties>
|
<properties>
|
||||||
<maven.compiler.source>1.8</maven.compiler.source>
|
<maven.compiler.source>1.8</maven.compiler.source>
|
||||||
<maven.compiler.target>1.8</maven.compiler.target>
|
<maven.compiler.target>1.8</maven.compiler.target>
|
||||||
|
<!-- Spring -->
|
||||||
|
<spring-framework.version>4.0.3.RELEASE</spring-framework.version>
|
||||||
</properties>
|
</properties>
|
||||||
</project>
|
</project>
|
|
@ -16,6 +16,8 @@ import org.reflections.Reflections;
|
||||||
import org.reflections.scanners.SubTypesScanner;
|
import org.reflections.scanners.SubTypesScanner;
|
||||||
import org.reflections.util.ClasspathHelper;
|
import org.reflections.util.ClasspathHelper;
|
||||||
import org.reflections.util.ConfigurationBuilder;
|
import org.reflections.util.ConfigurationBuilder;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.jdbc.core.JdbcTemplate;
|
||||||
|
|
||||||
import com.sun.net.httpserver.HttpServer;
|
import com.sun.net.httpserver.HttpServer;
|
||||||
import io.github.norbipeti.chat.server.db.*;
|
import io.github.norbipeti.chat.server.db.*;
|
||||||
|
@ -23,9 +25,6 @@ import io.github.norbipeti.chat.server.db.domain.*;
|
||||||
import io.github.norbipeti.chat.server.page.*;
|
import io.github.norbipeti.chat.server.page.*;
|
||||||
|
|
||||||
public class Main {
|
public class Main {
|
||||||
// public static final HashMap<String, Page> Pages = new HashMap<String,
|
|
||||||
// Page>();
|
|
||||||
|
|
||||||
public static void main(String[] args) { // http://stackoverflow.com/questions/9266632/access-restriction-is-not-accessible-due-to-restriction-on-required-library/10642163#10642163
|
public static void main(String[] args) { // http://stackoverflow.com/questions/9266632/access-restriction-is-not-accessible-due-to-restriction-on-required-library/10642163#10642163
|
||||||
try { // rt.jar Javadoc:
|
try { // rt.jar Javadoc:
|
||||||
// https://docs.oracle.com/javase/8/docs/jre/api/net/httpserver/spec/
|
// https://docs.oracle.com/javase/8/docs/jre/api/net/httpserver/spec/
|
||||||
|
@ -36,7 +35,7 @@ public class Main {
|
||||||
user.setName("asd");
|
user.setName("asd");
|
||||||
user.setEmail("test@test.com");
|
user.setEmail("test@test.com");
|
||||||
User user2 = new User();
|
User user2 = new User();
|
||||||
user2.setName("Teszt");
|
user2.setName("Teszt"); //TODO: http://www.journaldev.com/3524/spring-hibernate-integration-example-tutorial
|
||||||
user2.setEmail("test2@test.com");
|
user2.setEmail("test2@test.com");
|
||||||
user2.getContacts().add(user);
|
user2.getContacts().add(user);
|
||||||
provider.save(user);
|
provider.save(user);
|
||||||
|
@ -51,7 +50,7 @@ public class Main {
|
||||||
LogManager.getLogger().log(Level.DEBUG, "2nd's contact: " + user2.getContacts().get(0));
|
LogManager.getLogger().log(Level.DEBUG, "2nd's contact: " + user2.getContacts().get(0));
|
||||||
Conversation convo = new Conversation();
|
Conversation convo = new Conversation();
|
||||||
convo.getUsers().add(user);
|
convo.getUsers().add(user);
|
||||||
//user.getConversations().add(convo);
|
// user.getConversations().add(convo);
|
||||||
convo.getUsers().add(user2);
|
convo.getUsers().add(user2);
|
||||||
// user2.getConversations().add(convo); - TODO: Fix duplicate
|
// user2.getConversations().add(convo); - TODO: Fix duplicate
|
||||||
// key constraint
|
// key constraint
|
||||||
|
|
Loading…
Reference in a new issue