GithubHelp home page GithubHelp logo

watson-developer-cloud / spring-boot-starter Goto Github PK

View Code? Open in Web Editor NEW
13.0 31.0 14.0 330 KB

Spring Boot support for Watson services

License: Apache License 2.0

Java 98.96% Shell 1.04%
spring-boot spring-boot-starter watson watson-developer-cloud ibm-watson-services watson-conversation watson-discovery watson-language-translator watson-natural-language-classifier hacktoberfest

spring-boot-starter's Introduction

Watson Spring Boot

Build and Test Deploy and Publish Maven Central CLA assistant

Deprecated builds

Build Status

This project adds Spring Boot support for the Watson services.

This means that you can now "auto-wire" any of the Watson services into your Spring Boot application using the standard Spring autoconfiguration framework.

Usage

All you need to do is:

  1. Add the Watson watson-spring-boot-starter dependency to your Spring Boot app:

    In your maven pom.xml

    <dependency>
      <groupId>com.ibm.watson.developer_cloud</groupId>
      <artifactId>watson-spring-boot-starter</artifactId>
      <version>2.3.6</version>
    </dependency>
    

    or in your gradle build.gradle, in the dependencies stanza, add

    compile 'com.ibm.watson.developer_cloud:watson-spring-boot-starter:2.3.6'
    
  2. Add your Watson service(s) credentials and version info to your application properties file. The standard location for application properties is the src/main/resources/application.properties file, but your application might use a different location. The properties to add are:

  • watson.<service>.url: The base URL for the service. This can be omitted if your service uses the default service url

  • watson.<service>.username and watson.<service>.password OR watson.<service>.apiKey OR watson.<service>.iamApiKey: The credentials for accessing the service. The credentials can be omitted from the application properties file if they are supplied through the VCAP_SERVICES environment variable.

  • watson.<service>.versionDate: Some Watson services use a versionDate parameter to indicate the service behavior expected by the application. For services that accept it, this is a required parameter and must be specified in the application properties.

    Both Eclipse and IntelliJ (Ultimate Edition) offer autocomplete support for Spring Boot application properties and should show these properties, along with their required type and Javadoc description, in the autocomplete menu.

  1. Autowire the service into your application. Autowiring is the key mechanism of the Spring framework for injecting dependencies. It is accomplished by specifying the @Autowired annotation on the declaration for the service instance. Here's an example using the Watson Conversation service:
@Autowired
protected Conversation service;

The Spring framework takes care of the rest. Your application can now simply start using the service instance.

Open Source @ IBM

Find more open source projects on the IBM Github Page

License

This library is licensed under Apache 2.0. Full license text is available in LICENSE.

Contributing

See CONTRIBUTING.md.

Code of Conduct

See CODE_OF_CONDUCT.md.

Other

If you are having difficulties using the APIs or you have a question about the IBM Watson Services, please ask a question on dW Answers or Stack Overflow.

spring-boot-starter's People

Contributors

apaparazzi0329 avatar germanattanasio avatar hsaylor avatar jeff-arn avatar ka4ok85 avatar kevinkowa avatar lpatino10 avatar mikemosca avatar tnixa avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

spring-boot-starter's Issues

Please update <service> name to comply with Spring Boot 2 rules for externalized configuration

Please see https://github.com/spring-projects/spring-boot/wiki/Spring-Boot-2.0-Migration-Guide#externalized-configuration:

All prefixes must be in kebab-case format (lower-case, hyphen separated), acme.myProject or acme.my_project are invalid - you must use acme.my-project here

Steps to reproduce:

  1. Spring Boot version: 2.0.0.M7
  2. Watson-spring-boot-starter version: 0.0.2
  3. During startup following error returned:

Configuration property name 'watson.language_translator' is not valid:

Invalid characters: '_' Bean: com.ibm.watson.developer_cloud.spring.boot.WatsonAutoConfiguration Reason: Canonical names should be kebab-case ('-' separated), lowercase alpha-numeric characters and must start with a letter

Modify 'watson.language_translator' so that it conforms to the canonical names requirements.

what if one of the dependency jar of our project doesn't follow kebab-case format for @ConfigurationProperties(prefix="MY_CONFIG"). Is there an option in spring boot 2.x to solve this problem ? This question is in reference to the below issue

Remember, an issue is not the place to ask questions. You can use Stack Overflow for that, or you may want to start a discussion on the dW Answers.

Before you open an issue, please check if a similar issue already exists or has been closed before.

When reporting a bug, please be sure to include the following:

  • Start the title with the service name in brackets: [speech-to-text] websockets...
  • Steps to reproduce
  • Expected behavior
  • Actual behavior
  • JDK version
  • java-sdk version

When you open an issue for a feature request, please add as much detail as possible:

  • A descriptive title starting with the service name
  • A description of the problem you're trying to solve
  • A suggested solution if possible

Cloud Pack Bearer Token

Is there a way to auto wire with bearer token as authentication?
Currently trying
watson.discovery.apiKey=
But from the source code I can tell this is using a Basic Authentication

Please push it to Maven

Hello,

Do you have any timeline on when spring-boot-starter Artifact will be available through Maven?

Thanks!

Rename to comply with Spring Boot's naming guidelines

The Spring Boot documentation requests that third-party starters be named *-spring-boot-starter. The current name of this module, spring-boot-starter, is particularly bad as it clashes with one of Spring Boot's own modules. watson-spring-boot-starter would, IMO, be a better name. Also, please note that the naming scheme that's recommended in the reference documentation is also a requirement for inclusion on start.spring.io.

[Watson-Discovery]Bean of type 'com.ibm.watson.discovery.v2.Discovery' that could not be found.

Issue - Bean of type 'com.ibm.watson.discovery.v2.Discovery' could not be found.
JDK version - 11

Steps to reproduce
Autowired Discovery

  1. @Autowired
    Discovery discovery;

  2. pom.xml

    11 org.springframework.boot spring-boot-starter-web
     <dependency>
     	<groupId>com.ibm.watson.developer_cloud</groupId>
     	<artifactId>watson-spring-boot-starter</artifactId>
     	<version>2.1.4</version>
     </dependency>
    
     <dependency>
     	<groupId>org.springframework.boot</groupId>
     	<artifactId>spring-boot-starter-test</artifactId>
     	<scope>test</scope>
     </dependency>
    
  3. Packages used in code
    import com.ibm.cloud.sdk.core.http.Response;
    import com.ibm.watson.discovery.v2.Discovery;
    import com.ibm.watson.discovery.v2.model.QueryOptions;
    import com.ibm.watson.discovery.v2.model.QueryResponse;

I am not able to find answers on other forums like stackoverflow. May be I am missing some dependencies in pom.xml.

Stack Trace


APPLICATION FAILED TO START


Description:

Field discovery in com.xyz.search.controller.SearchController required a bean of type 'com.ibm.watson.discovery.v2.Discovery' that could not be found.

The injection point has the following annotations:
- @org.springframework.beans.factory.annotation.Autowired(required=true)

Action:

Consider defining a bean of type 'com.ibm.watson.discovery.v2.Discovery' in your configuration.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.