1
我已经使用spring-boot和neo4j创建了应用程序。以下是Neo4j的如何在单弹簧引导应用程序中使用MySQL和neo4j
@Configuration
@ComponentScan({ "myproject" })
@EnableAutoConfiguration
@EnableNeo4jRepositories(basePackages = "myproject")
public class Neo4jServer extends Neo4jConfiguration implements CommandLineRunner
{
public Server()
{
setBasePackage("myproject");
}
@Bean
SpringRestGraphDatabase graphDatabaseService()
{
return new SpringRestGraphDatabase("http://localhost:7474/db/data");
}
public void run(String... args) throws Exception
{
}
public static void main(String[] args) throws Exception
{
SpringApplication.run(Neo4jServer.class, args);
}
}
春季启动应用程序,以下是春季启动应用与MySQL
@Configuration
@ComponentScan({ "myproject" })
@EnableAutoConfiguration
@EnableJpaRepositories(basePackages = "myproject.persistence")
@PropertySource("myproject.properties")
public class MySQLServer extends DataSourceAutoConfiguration implements CommandLineRunner
{
public void run(String... args) throws Exception
{
}
public static void main(String[] args) throws Exception
{
SpringApplication.run(MySQLServer.class, args);
}
}
我已经创建的属性在资源包文件。
spring.datasource.url=jdbc:mysql://localhost:3306/myDB
spring.datasource.username=root
spring.datasource.password=root
spring.datasource.driverClassName=com.mysql.jdbc.Driver
所以,现在有两个应用,一个是用Neo4j的即Neo4jServer.java,一个是与MySQL即MySQLServer.java 如何既单一应用程序中使用。 如果错了,请让我纠正。 谢谢:)
创建属性文件的MySQL数据库性能。但不知道该怎么做? – 2014-10-10 06:55:35
查看http://spring.io/guides/gs/accessing-data-jpa/ – geoand 2014-10-10 07:01:52
以下是如何在引导应用程序中使用neo4j-jdbc:https://github.com/neo4j-contrib/developer- resources/tree/gh-pages/language-guides/java/spring-boot-jdbc – 2014-10-10 15:02:31