<commit_before>[[reference.getting_started]]
= Getting started

Depending on what type of project you are doing there are several options when it comes to creating a new SDN project:

- Use http://start.spring.io (for Spring Boot projects);
- Use the https://spring.io/tools/sts[Spring Tool Suite (based on eclipse)];
- Adding the required libraries using your dependency management tool.


If you plan on using Neo4j in server mode, you will also need a running instance.  Refer to the Getting Started section of the http://neo4j.com/docs/developer-manual/current/get-started[Neo4j Developer manual] on
how to get that up and running.

== Using Boot

To create a Spring Boot project simply go to http://start.spring.io and specify a group and artifact like: `org.spring.neo4j.example` and `demo`.
In the ***Dependencies*** box type: "Neo4J".  You can also add any other Spring support like "Web" etc. Once you are satisfied with your dependencies
hit the generate button, download the zip and unzip into your workspace.


== Using STS

To create a Spring project in STS go to File → New → Spring Template Project → Simple Spring Utility Project → press Yes when prompted. Then enter a project and a package name such as `org.spring.neo4j.example`.

Then add the following to pom.xml dependencies section.

[source,xml]
----
<dependencies>

  <!-- other dependency elements omitted -->

  <dependency>
    <groupId>org.springframework.data</groupId>
    <artifactId>spring-data-neo4j</artifactId>
    <version>{version}</version>
  </dependency>

</dependencies>
----

Also change the version of Spring in the pom.xml to be

[source,xml]
----
<spring.framework.version>{springVersion}</spring.framework.version>
----



[[reference.getting_started.dependencies]]
== Using Dependency Management

Spring Data Neo4j projects can be built using Maven, Gradle or any other tool that supports Maven's repository system.

[NOTE]
For more in depth configuration details please consult the Configuration section of the OGM Reference Manual.

[[reference.getting_started.dependencies.maven]]
=== Maven

By default, SDN will use the BOLT driver to connect to Neo4j and you don't need to declare it as a separate dependency in your pom.
If you want to use the embedded or HTTP drivers in your production application, you must add the following dependencies as well.
(This dependency on the embedded driver is not required if you only want to use the embedded driver for testing. See the section on <<testing,Testing>> below for more information).



[source,xml]
----
<dependency>
    <groupId>org.springframework.data</groupId>
    <artifactId>spring-data-neo4j</artifactId>
    <version>{version}</version>
</dependency>

<!-- add this dependency if you want to use the embedded driver -->
<dependency>
    <groupId>org.neo4j</groupId>
    <artifactId>neo4j-ogm-embedded-driver</artifactId>
    <version>{ogm-version}</version>
</dependency>

<!-- add this dependency if you want to use the HTTP driver -->
<dependency>
    <groupId>org.neo4j</groupId>
    <artifactId>neo4j-ogm-http-driver</artifactId>
    <version>{ogm-version}</version>
</dependency>
----


[[reference.getting_started.dependencies.testing]]
==== Testing

.Maven dependencies for testing SDN 5 applications
[source,xml]
----
       <dependency>
           <groupId>org.springframework.data</groupId>
           <artifactId>spring-data-neo4j</artifactId>
           <version>${sdn.version}</version>
           <type>test-jar</type>
       </dependency>

       <!-- the neo4j-ogm-test jar provides access to the http and embedded drivers for testing purposes -->
       <dependency>
          <groupId>org.neo4j</groupId>
          <artifactId>neo4j-ogm-test</artifactId>
          <version>${neo4j-ogm.version}</version>
          <type>test-jar</type>
          <scope>test</scope>
      </dependency>

       <dependency>
           <groupId>org.neo4j</groupId>
            <artifactId>neo4j-kernel</artifactId>
            <version>${neo4j.version}</version>
            <type>test-jar</type>
       </dependency>

       <dependency>
            <groupId>org.neo4j.app</groupId>
            <artifactId>neo4j-server</artifactId>
            <version>${neo4j.version}</version>
            <type>test-jar</type>
       </dependency>

      <dependency>
          <groupId>org.neo4j.test</groupId>
          <artifactId>neo4j-harness</artifactId>
          <version>${neo4j.version}</version>
          <scope>test</scope>
      </dependency>
----

[NOTE]
====
The `InProcessServer` has been deprecated. This class was used in previous versions to set up an in-memory Http server so that you could run your tests.
This is no longer appropriate given the new Driver mechanism, and we recommend you configure an Embedded Driver (impermanent data store) for your integration tests instead.
====


[[reference.getting_started.dependencies.gradle]]
=== Gradle

Gradle dependencies are basically the same as Maven:

[source,groovy]
----
dependencies {
    compile 'org.springframework.data:spring-data-neo4j:{version}'

    # add this dependency if you want to use the embedded driver
    compile 'org.neo4j:neo4j-ogm-embedded-driver:{ogm-version}'

    # add this dependency if you want to use the Http driver
    compile 'org.neo4j:neo4j-ogm-http-driver:{ogm-version}'

}
----

== Examples
There is an https://github.com/spring-projects/spring-data-examples[github repository with several examples] that you can download and play around with to get a feel for how the library works.


[[reference.getting_started.spring-configuration]]
== Configuration

Right now SDN only supports JavaConfig. There is no XML based support but this may change in future.

[NOTE]
For those not familiar with how to configure the Spring container using Java based bean metadata instead of XML based metadata see the high level introduction in the reference docs http://docs.spring.io/spring/docs/3.2.x/spring-framework-reference/html/new-in-3.0.html#new-java-configuration[here] as well as the detailed documentation http://docs.spring.io/spring/docs/4.2.9.RELEASE/spring-framework-reference/html/beans.html#beans-java-instantiating-container[here].


For most applications the following configuration is all that's needed to get up and running.


.Spring Data Neo4j repositories using JavaConfig
[source,java]
----
@Configuration
@EnableNeo4jRepositories(basePackages = "org.neo4j.example.repository")
@EnableTransactionManagement
public class MyConfiguration {

    @Bean
    public SessionFactory sessionFactory() {
        // with domain entity base package(s)
        return new SessionFactory("org.neo4j.example.domain");
    }<commit_msg>DATAGRAPH-981 - Update documentation with new features and API changes.<commit_after>[[reference.getting_started]]
= Getting started

Depending on what type of project you are doing there are several options when it comes to creating a new SDN project:

- Use http://start.spring.io (for Spring Boot projects);
- Use the https://spring.io/tools/sts[Spring Tool Suite (based on eclipse)];
- Adding the required libraries using your dependency management tool.


If you plan on using Neo4j in server mode, you will also need a running instance.  Refer to the Getting Started section of the http://neo4j.com/docs/developer-manual/current/get-started[Neo4j Developer manual] on
how to get that up and running.

== Using Boot

To create a Spring Boot project simply go to http://start.spring.io and specify a group and artifact like: `org.spring.neo4j.example` and `demo`.
In the ***Dependencies*** box type: "Neo4J".  You can also add any other Spring support like "Web" etc. Once you are satisfied with your dependencies
hit the generate button, download the zip and unzip into your workspace.


== Using STS

To create a Spring project in STS go to File → New → Spring Template Project → Simple Spring Utility Project → press Yes when prompted. Then enter a project and a package name such as `org.spring.neo4j.example`.

Then add the following to pom.xml dependencies section.

[source,xml]
----
<dependencies>

  <!-- other dependency elements omitted -->

  <dependency>
    <groupId>org.springframework.data</groupId>
    <artifactId>spring-data-neo4j</artifactId>
    <version>{version}</version>
  </dependency>

</dependencies>
----

Also change the version of Spring in the pom.xml to be

[source,xml]
----
<spring.framework.version>{springVersion}</spring.framework.version>
----



[[reference.getting_started.dependencies]]
== Using Dependency Management

Spring Data Neo4j projects can be built using Maven, Gradle or any other tool that supports Maven's repository system.

[NOTE]
For more in depth configuration details please consult the Configuration section of the OGM Reference Manual.

[[reference.getting_started.dependencies.maven]]
=== Maven

By default, SDN will use the BOLT driver to connect to Neo4j and you don't need to declare it as a separate dependency in your pom.
If you want to use the embedded or HTTP drivers in your production application, you must add the following dependencies as well.
(This dependency on the embedded driver is not required if you only want to use the embedded driver for testing. See the section on <<testing,Testing>> below for more information).



[source,xml]
----
<dependency>
    <groupId>org.springframework.data</groupId>
    <artifactId>spring-data-neo4j</artifactId>
    <version>{version}</version>
</dependency>

<!-- add this dependency if you want to use the embedded driver -->
<dependency>
    <groupId>org.neo4j</groupId>
    <artifactId>neo4j-ogm-embedded-driver</artifactId>
    <version>{ogm-version}</version>
</dependency>

<!-- add this dependency if you want to use the HTTP driver -->
<dependency>
    <groupId>org.neo4j</groupId>
    <artifactId>neo4j-ogm-http-driver</artifactId>
    <version>{ogm-version}</version>
</dependency>
----


[[reference.getting_started.dependencies.testing]]
==== Testing

.Maven dependencies for testing SDN 5 applications
[source,xml]
----
       <dependency>
           <groupId>org.springframework.data</groupId>
           <artifactId>spring-data-neo4j</artifactId>
           <version>${sdn.version}</version>
           <type>test-jar</type>
       </dependency>

       <!-- the neo4j-ogm-test jar provides access to the http and embedded drivers for testing purposes -->
       <dependency>
          <groupId>org.neo4j</groupId>
          <artifactId>neo4j-ogm-test</artifactId>
          <version>${neo4j-ogm.version}</version>
          <type>test-jar</type>
          <scope>test</scope>
      </dependency>

       <dependency>
           <groupId>org.neo4j</groupId>
            <artifactId>neo4j-kernel</artifactId>
            <version>${neo4j.version}</version>
            <type>test-jar</type>
       </dependency>

       <dependency>
            <groupId>org.neo4j.app</groupId>
            <artifactId>neo4j-server</artifactId>
            <version>${neo4j.version}</version>
            <type>test-jar</type>
       </dependency>

      <dependency>
          <groupId>org.neo4j.test</groupId>
          <artifactId>neo4j-harness</artifactId>
          <version>${neo4j.version}</version>
          <scope>test</scope>
      </dependency>
----

[NOTE]
====
The `InProcessServer` has been deprecated. This class was used in previous versions to set up an in-memory Http server so that you could run your tests.
This is no longer appropriate given the new Driver mechanism, and we recommend you configure an Embedded Driver (impermanent data store) for your integration tests instead.
====


[[reference.getting_started.dependencies.gradle]]
=== Gradle

Gradle dependencies are basically the same as Maven:

[source,groovy]
----
dependencies {
    compile 'org.springframework.data:spring-data-neo4j:{version}'

    # add this dependency if you want to use the embedded driver
    compile 'org.neo4j:neo4j-ogm-embedded-driver:{ogm-version}'

    # add this dependency if you want to use the Http driver
    compile 'org.neo4j:neo4j-ogm-http-driver:{ogm-version}'

}
----

== Examples
There is an https://github.com/spring-projects/spring-data-examples[github repository with several examples] that you can download and play around with to get a feel for how the library works.


[[reference.getting_started.spring-configuration]]
== Configuration

Right now SDN only supports JavaConfig. There is no XML based support but this may change in future.

[NOTE]
For those not familiar with how to configure the Spring container using Java based bean metadata instead of XML based metadata see the high level introduction in the reference docs http://docs.spring.io/spring/docs/3.2.x/spring-framework-reference/html/new-in-3.0.html#new-java-configuration[here] as well as the detailed documentation http://docs.spring.io/spring/docs/4.2.9.RELEASE/spring-framework-reference/html/beans.html#beans-java-instantiating-container[here].


For most applications the following configuration is all that's needed to get up and running.


.Spring Data Neo4j repositories using JavaConfig
[source,java]
----
@Configuration
@EnableNeo4jRepositories(basePackages = "org.neo4j.example.repository")
@EnableTransactionManagement
public class MyConfiguration {

    @Bean
    public SessionFactory sessionFactory() {
        // with domain entity base package(s)
        return new SessionFactory(configuration(), "org.neo4j.example.domain");
    }

    @Bean
    public org.neo4j.ogm.config.Configuration configuration() {
        ConfigurationSource properties = new ClasspathConfigurationSource("ogm.properties");
        org.neo4j.ogm.config.Configuration configuration = new org.neo4j.ogm.config.Configuration.Builder(properties)
        return configuration;
    }
{'fraction_non_alphanumeric': 0.10449495316244281, 'fraction_numerical': 0.006971171302011473, 'mean_word_length': 3.6417256488035052, 'pattern_counts': {'":': 0, '<': 191, '<?xml version=': 0, '>': 191, 'https://': 4, 'lorem ipsum': 0, 'www.': 0, 'xml': 12}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 6, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4816572', 'n_tokens_mistral': 3965, 'n_tokens_neox': 3662, 'n_words': 1311}