Skip to content

henryxwong/SpringSheets

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

SpringSheets

Use Google Sheets as Spring property files

Features

Requirements

  • Java 7
  • Spring Framework 4+
  • Google Account
  • Works with Spring Boot (Optional)

Maven

Not at the moment, I will put the lib into maven central if it got enough public interest. Please download the source and build it yourself at current stage.

Usage

  1. You should first follow this guide to turn on your Google Sheets API https://developers.google.com/sheets/api/quickstart/java

  2. Copy the generated client_secret.json file to your classpath

  3. Annotate your Spring bean/config with @PropertySource with

    • name - a unique name for the property source
    • value - in this format <spreadsheetId,rangeName>

For example:

@Component
@PropertySources(
        {
                @PropertySource(name = "FeeTable", value = "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX,TradingFee", factory = SpringSheetsPropertySourceFactory.class),
                @PropertySource(name = "ForexTable", value = "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX,ForexRate", factory = SpringSheetsPropertySourceFactory.class)
        }
)
@ConfigurationProperties(prefix = "trading")
public class Config {
    ...
}

With a named range TradingFee in table style (headers required)

takerTradingFee makerTradingFee
trading.fee[BTC/USD] 0.001 0.001
trading.fee[ETH/USD] 0.001 0.001
trading.fee[ETH/BTC] 0.001 0.001

and a named range ForexRate in name-value pairs style

trading.fxRate[USD/HKD] 7.85
trading.fxRate[EUR/HKD] 9.75

About

Use Google Sheets as Spring property files

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages