2017-01-26 4 views
1

私はさまざまなチュートリアルに続いて、以下の設定を完了しました。問題の原因となる設定が誤っている可能性もあります。私がテストを実行すると、私が手:Springアプリケーションに埋め込みDynamoDBをロードするのに適したドライバは何ですか?

Caused by: org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.apache.tomcat.jdbc.pool.DataSource]: Factory method 'dataSource' threw exception; nested exception is org.springframework.boot.autoconfigure.jdbc.DataSourceProperties$DataSourceBeanCreationException: Cannot determine embedded database driver class for database type NONE. If you want an embedded database please put a supported one on the classpath. If you have database settings to be loaded from a particular profile you may need to active it (the profiles "test" are currently active). 

研究は、適切なドライバがロードされていないと私は.propertiesに追加する必要があることを信じて私をリードしています。それはDynamoDBLocalライブラリに含まれていますか?私はドキュメントでそれを見つけることができないし、私の唯一のオプションは、Webからサードパーティのドライバを取得することです。ここで

のは、重要な部分は、以下のとおりです。

のpom.xml:

<dependency> 
     <groupId>com.amazonaws</groupId> 
     <artifactId>aws-java-sdk-dynamodb</artifactId> 
     <version>1.11.34</version> 
    </dependency> 
    <dependency> 
     <groupId>com.github.derjust</groupId> 
     <artifactId>spring-data-dynamodb</artifactId> 
     <version>4.3.1</version> 
    </dependency> 
    <dependency> 
     <groupId>com.amazonaws</groupId> 
     <artifactId>DynamoDBLocal</artifactId> 
     <version>1.10.5.1</version> 
    </dependency> 

DataSourceConfigLocal:

@Configuration 
@EnableWebMvc 
@EnableDynamoDBRepositories(basePackages="com.cfa.dao") 
@Profile({"local", "test"}) 
public class DataSourceConfigLocal { 

    @Value("${amazon.dynamodb.endpoint}") 
    private String amazonDynamoDBEndpoint; 

    @Value("${amazon.aws.accesskey}") 
    private String amazonAWSAccessKey; 

    @Value("${amazon.aws.secretkey}") 
    private String amazonAWSSecretKey; 

    @Bean 
    public AmazonDynamoDB amazonDynamoDB() { 
     AmazonDynamoDB amazonDynamoDB 
       = new AmazonDynamoDBClient(amazonAWSCredentials()); 

     if (!StringUtils.isEmpty(amazonDynamoDBEndpoint)) { 
      amazonDynamoDB.setEndpoint(amazonDynamoDBEndpoint); 
     } 

     return amazonDynamoDB; 
    } 

    @Bean 
    public AWSCredentials amazonAWSCredentials() { 
     return new BasicAWSCredentials(
       amazonAWSAccessKey, amazonAWSSecretKey); 
    } 
} 

IntegrationTest:

@RunWith(SpringJUnit4ClassRunner.class) 
@WebAppConfiguration 
@Profile("test") 
@TestPropertySource(properties = { 
     "amazon.dynamodb.endpoint=http://localhost:8000/", 
     "amazon.aws.accesskey=x", 
     "amazon.aws.secretkey=x" }) 
public class OrderRequestRepositoryIntegrationTest { 

    private DynamoDBMapper dynamoDBMapper; 

    @Autowired 
    private AmazonDynamoDB amazonDynamoDB; 

    @Autowired 
    OrderRequestDao orderRequestDao; 

    private static final String STORE_NUMBER = "100"; 

    @Before 
    public void setup() throws Exception { 
     dynamoDBMapper = new DynamoDBMapper(amazonDynamoDB); 

     CreateTableRequest tableRequest = dynamoDBMapper 
       .generateCreateTableRequest(OrderRequest.class); 
     tableRequest.setProvisionedThroughput(
       new ProvisionedThroughput(1L, 1L)); 
     amazonDynamoDB.createTable(tableRequest); 

     dynamoDBMapper.batchDelete(
       (List<OrderRequest>)orderRequestDao.findAll()); 
    } 

    @Test 
    public void sampleTestCase() { 
     OrderRequest orderRequest = new OrderRequest(STORE_NUMBER); 
     orderRequestDao.save(orderRequest); 

     List<OrderRequest> result 
       = (List<OrderRequest>) orderRequestDao.findAll(); 

     assertTrue("Not empty", result.size() > 0); 
     assertTrue("Contains item with expected cost", 
       result.get(0).getStoreNumber().equals(STORE_NUMBER)); 
    } 
} 

答えて

0

私はあなたが持っているかどうかわかりません既に参照された この。私はあなたを助けるかもしれないので、これを追加しています。

Test using HTTP and without using HTTP

pom file which has the server runner and sql lite

1)また、JARの最新バージョン1.11.0.1を使用しています。クラスパスに

2)SQL Liteのlibに

<dependency> 
    <groupId>com.amazonaws</groupId> 
    <artifactId>DynamoDBLocal</artifactId> 
    <version>${aws.dynamodblocal.version}</version> 
</dependency> 

<profile> 
      <id>start-dynamodb-local</id> 
      <build> 
       <plugins> 
        <plugin> 
         <groupId>org.codehaus.mojo</groupId> 
         <artifactId>exec-maven-plugin</artifactId> 
         <version>${exec.maven.plugin.version}</version> 
         <executions> 
          <execution> 
           <phase>initialize</phase> 
           <configuration> 
            <executable>java</executable> 
            <arguments> 
             <argument>-cp</argument> 
             <classpath/> 
             <argument>-Dsqlite4java.library.path=${basedir}/target/dependencies</argument> 
             <argument>com.amazonaws.services.dynamodbv2.local.main.ServerRunner</argument> 
             <argument>-inMemory</argument> 
             <argument>-port</argument> 
             <argument>${dynamodb-local.port}</argument> 
            </arguments> 
           </configuration> 
           <goals> 
            <goal>exec</goal> 
           </goals> 
          </execution> 
         </executions> 
        </plugin> 
       </plugins> 
      </build> 
     </profile> 
+0

私はこれは私がいる問題に対処するためのものですかどうかはわかりません。 –

関連する問題