Ver código fonte

initial commit

dongbw 8 anos atrás
commit
4b7983fdda

+ 30 - 0
.gitignore

@@ -0,0 +1,30 @@
+### Gradle template
+.gradle
+classes/
+target/
+build/
+out/
+
+# Ignore Gradle GUI config
+gradle-app.setting
+
+# Avoid ignoring Gradle wrapper jar file (.jar files are usually ignored)
+!gradle-wrapper.jar
+
+### Java template
+*.log
+
+# Package Files #
+#*.jar
+*.war
+*.ear
+
+# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
+hs_err_pid*
+
+# Created by .ignore support plugin (hsz.mobi)
+
+# IntelliJ IDEA
+*.iml
+.idea/
+.idea_modules/

+ 41 - 0
build.gradle

@@ -0,0 +1,41 @@
+buildscript {
+    ext {
+        springBootVersion = '1.4.4.RELEASE'
+        springloadedVersion = '1.2.6.RELEASE'
+    }
+    repositories {
+        mavenCentral()
+        jcenter()
+    }
+    dependencies {
+        classpath("org.springframework.boot:spring-boot-gradle-plugin:${springBootVersion}")
+    }
+}
+
+group = 'com.uas.cloud.mall'
+version = '0.1'
+
+apply plugin: 'java'
+apply plugin: 'org.springframework.boot'
+
+sourceCompatibility = 1.8 // 必须在apply java插件之后
+targetCompatibility = 1.8
+
+repositories {
+    mavenCentral()
+}
+
+dependencyManagement {
+    imports {
+        mavenBom 'org.springframework.cloud:spring-cloud-dependencies:Camden.SR5'
+    }
+}
+dependencies {
+    compile "org.springframework.boot:spring-boot-starter-data-jpa"
+    compile "mysql:mysql-connector-java:5.1.21"
+    compile 'org.springframework.cloud:spring-cloud-starter-config'
+    compile "org.springframework.cloud:spring-cloud-starter-eureka"
+    compile "com.alibaba:fastjson:1.2.24"
+    compile("org.springframework.boot:spring-boot-devtools")
+    testCompile 'org.springframework.boot:spring-boot-starter-test'
+}

BIN
gradle/wrapper/gradle-wrapper.jar


+ 6 - 0
gradle/wrapper/gradle-wrapper.properties

@@ -0,0 +1,6 @@
+#Thu Mar 02 17:40:45 CST 2017
+distributionBase=GRADLE_USER_HOME
+distributionPath=wrapper/dists
+zipStoreBase=GRADLE_USER_HOME
+zipStorePath=wrapper/dists
+distributionUrl=https\://services.gradle.org/distributions/gradle-2.14.1-bin.zip

+ 164 - 0
gradlew

@@ -0,0 +1,164 @@
+#!/usr/bin/env bash
+
+##############################################################################
+##
+##  Gradle start up script for UN*X
+##
+##############################################################################
+
+# Attempt to set APP_HOME
+# Resolve links: $0 may be a link
+PRG="$0"
+# Need this for relative symlinks.
+while [ -h "$PRG" ] ; do
+    ls=`ls -ld "$PRG"`
+    link=`expr "$ls" : '.*-> \(.*\)$'`
+    if expr "$link" : '/.*' > /dev/null; then
+        PRG="$link"
+    else
+        PRG=`dirname "$PRG"`"/$link"
+    fi
+done
+SAVED="`pwd`"
+cd "`dirname \"$PRG\"`/" >/dev/null
+APP_HOME="`pwd -P`"
+cd "$SAVED" >/dev/null
+
+APP_NAME="Gradle"
+APP_BASE_NAME=`basename "$0"`
+
+# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
+DEFAULT_JVM_OPTS=""
+
+# Use the maximum available, or set MAX_FD != -1 to use that value.
+MAX_FD="maximum"
+
+warn ( ) {
+    echo "$*"
+}
+
+die ( ) {
+    echo
+    echo "$*"
+    echo
+    exit 1
+}
+
+# OS specific support (must be 'true' or 'false').
+cygwin=false
+msys=false
+darwin=false
+nonstop=false
+case "`uname`" in
+  CYGWIN* )
+    cygwin=true
+    ;;
+  Darwin* )
+    darwin=true
+    ;;
+  MINGW* )
+    msys=true
+    ;;
+  NONSTOP* )
+    nonstop=true
+    ;;
+esac
+
+CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
+
+# Determine the Java command to use to start the JVM.
+if [ -n "$JAVA_HOME" ] ; then
+    if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
+        # IBM's JDK on AIX uses strange locations for the executables
+        JAVACMD="$JAVA_HOME/jre/sh/java"
+    else
+        JAVACMD="$JAVA_HOME/bin/java"
+    fi
+    if [ ! -x "$JAVACMD" ] ; then
+        die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
+
+Please set the JAVA_HOME variable in your environment to match the
+location of your Java installation."
+    fi
+else
+    JAVACMD="java"
+    which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
+
+Please set the JAVA_HOME variable in your environment to match the
+location of your Java installation."
+fi
+
+# Increase the maximum file descriptors if we can.
+if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then
+    MAX_FD_LIMIT=`ulimit -H -n`
+    if [ $? -eq 0 ] ; then
+        if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
+            MAX_FD="$MAX_FD_LIMIT"
+        fi
+        ulimit -n $MAX_FD
+        if [ $? -ne 0 ] ; then
+            warn "Could not set maximum file descriptor limit: $MAX_FD"
+        fi
+    else
+        warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
+    fi
+fi
+
+# For Darwin, add options to specify how the application appears in the dock
+if $darwin; then
+    GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
+fi
+
+# For Cygwin, switch paths to Windows format before running java
+if $cygwin ; then
+    APP_HOME=`cygpath --path --mixed "$APP_HOME"`
+    CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
+    JAVACMD=`cygpath --unix "$JAVACMD"`
+
+    # We build the pattern for arguments to be converted via cygpath
+    ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
+    SEP=""
+    for dir in $ROOTDIRSRAW ; do
+        ROOTDIRS="$ROOTDIRS$SEP$dir"
+        SEP="|"
+    done
+    OURCYGPATTERN="(^($ROOTDIRS))"
+    # Add a user-defined pattern to the cygpath arguments
+    if [ "$GRADLE_CYGPATTERN" != "" ] ; then
+        OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
+    fi
+    # Now convert the arguments - kludge to limit ourselves to /bin/sh
+    i=0
+    for arg in "$@" ; do
+        CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
+        CHECK2=`echo "$arg"|egrep -c "^-"`                                 ### Determine if an option
+
+        if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then                    ### Added a condition
+            eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
+        else
+            eval `echo args$i`="\"$arg\""
+        fi
+        i=$((i+1))
+    done
+    case $i in
+        (0) set -- ;;
+        (1) set -- "$args0" ;;
+        (2) set -- "$args0" "$args1" ;;
+        (3) set -- "$args0" "$args1" "$args2" ;;
+        (4) set -- "$args0" "$args1" "$args2" "$args3" ;;
+        (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
+        (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
+        (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
+        (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
+        (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
+    esac
+fi
+
+# Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules
+function splitJvmOpts() {
+    JVM_OPTS=("$@")
+}
+eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS
+JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME"
+
+exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@"

+ 90 - 0
gradlew.bat

@@ -0,0 +1,90 @@
+@if "%DEBUG%" == "" @echo off
+@rem ##########################################################################
+@rem
+@rem  Gradle startup script for Windows
+@rem
+@rem ##########################################################################
+
+@rem Set local scope for the variables with windows NT shell
+if "%OS%"=="Windows_NT" setlocal
+
+set DIRNAME=%~dp0
+if "%DIRNAME%" == "" set DIRNAME=.
+set APP_BASE_NAME=%~n0
+set APP_HOME=%DIRNAME%
+
+@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
+set DEFAULT_JVM_OPTS=
+
+@rem Find java.exe
+if defined JAVA_HOME goto findJavaFromJavaHome
+
+set JAVA_EXE=java.exe
+%JAVA_EXE% -version >NUL 2>&1
+if "%ERRORLEVEL%" == "0" goto init
+
+echo.
+echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
+echo.
+echo Please set the JAVA_HOME variable in your environment to match the
+echo location of your Java installation.
+
+goto fail
+
+:findJavaFromJavaHome
+set JAVA_HOME=%JAVA_HOME:"=%
+set JAVA_EXE=%JAVA_HOME%/bin/java.exe
+
+if exist "%JAVA_EXE%" goto init
+
+echo.
+echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
+echo.
+echo Please set the JAVA_HOME variable in your environment to match the
+echo location of your Java installation.
+
+goto fail
+
+:init
+@rem Get command-line arguments, handling Windows variants
+
+if not "%OS%" == "Windows_NT" goto win9xME_args
+if "%@eval[2+2]" == "4" goto 4NT_args
+
+:win9xME_args
+@rem Slurp the command line arguments.
+set CMD_LINE_ARGS=
+set _SKIP=2
+
+:win9xME_args_slurp
+if "x%~1" == "x" goto execute
+
+set CMD_LINE_ARGS=%*
+goto execute
+
+:4NT_args
+@rem Get arguments from the 4NT Shell from JP Software
+set CMD_LINE_ARGS=%$
+
+:execute
+@rem Setup the command line
+
+set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
+
+@rem Execute Gradle
+"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
+
+:end
+@rem End local scope for the variables with windows NT shell
+if "%ERRORLEVEL%"=="0" goto mainEnd
+
+:fail
+rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
+rem the _cmd.exe /c_ return code!
+if  not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
+exit /b 1
+
+:mainEnd
+if "%OS%"=="Windows_NT" endlocal
+
+:omega

+ 1 - 0
settings.gradle

@@ -0,0 +1 @@
+rootProject.name = 'mall-news-service'

+ 19 - 0
src/main/java/com/uas/cloud/mall/shop/news/NewsApplication.java

@@ -0,0 +1,19 @@
+package com.uas.cloud.mall.shop.news;
+
+import org.springframework.boot.autoconfigure.SpringBootApplication;
+import org.springframework.boot.builder.SpringApplicationBuilder;
+import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
+
+/**
+ *  新闻资讯服务
+ *
+ * Created by dongbw on 17/02/25.
+ */
+
+@EnableDiscoveryClient
+@SpringBootApplication
+public class NewsApplication {
+    public static void main(String[] args) {
+        new SpringApplicationBuilder(NewsApplication.class).web(true).run(args);
+    }
+}

+ 101 - 0
src/main/java/com/uas/cloud/mall/shop/news/api/NewsController.java

@@ -0,0 +1,101 @@
+package com.uas.cloud.mall.shop.news.api;
+
+import com.alibaba.fastjson.JSON;
+import com.uas.cloud.mall.shop.news.model.News;
+import com.uas.cloud.mall.shop.news.service.NewsService;
+import org.apache.log4j.LogManager;
+import org.apache.log4j.Logger;
+import org.json.JSONML;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.cloud.client.ServiceInstance;
+import org.springframework.cloud.client.discovery.DiscoveryClient;
+import org.springframework.http.HttpHeaders;
+import org.springframework.http.HttpStatus;
+import org.springframework.http.ResponseEntity;
+import org.springframework.web.bind.annotation.*;
+import org.springframework.web.util.UriComponentsBuilder;
+
+import java.lang.reflect.Parameter;
+import java.net.URI;
+import java.util.Date;
+import java.util.List;
+
+/**
+ * 新闻服务api
+ *
+ * Created by dongbw on 17/02/25.
+ */
+
+@RestController
+@RequestMapping("/news")
+public class NewsController {
+
+    private final Logger logger = LogManager.getLogger(getClass());
+
+    @Autowired
+    private DiscoveryClient client;
+
+    @Autowired
+    private NewsService newsService;
+
+    /**
+     * 根据id获取某条新闻
+     *
+     * @param id
+     * @return
+     */
+    @RequestMapping(value="/{id}", method = RequestMethod.GET, produces = "application/json")
+    public News get(@PathVariable Long id) {
+        ServiceInstance instance = client.getLocalServiceInstance();
+        logger.info("/news, method: get, host:" + instance.getHost() + ", serviceId:" + instance.getServiceId() + ",news: " + id);
+        News news = newsService.findone(id);
+        return news;
+    }
+
+    /**
+     *  获取num条最新新闻
+     *
+     * @return
+     */
+    @RequestMapping(value="/created" ,method = RequestMethod.GET, produces = "application/json")
+    public List<News> getNewsByCreated() {
+        ServiceInstance instance = client.getLocalServiceInstance();
+        logger.info("/news, get, host:" + instance.getHost() + ", serviceId:" + instance.getServiceId() + "get news order by created time");
+        List<News> newsList = newsService.findBycreated();
+        System.out.println("读取到新闻" + JSON.toJSONString(newsList));
+        return newsList;
+    }
+
+    /**
+     *  获取最多点击量新闻
+     *
+     * @return
+     */
+    @RequestMapping(value="/viewcount" ,method = RequestMethod.GET, produces = "application/json")
+    public List<News> getNewsByViewCount() {
+        ServiceInstance instance = client.getLocalServiceInstance();
+        logger.info("/news, get, host:" + instance.getHost() + ", serviceId:" + instance.getServiceId() + "get news order by viewcount");
+        List<News> newsList = newsService.findByViewCount();
+        return newsList;
+    }
+
+
+    @RequestMapping(method = RequestMethod.POST, consumes = "application/json")
+    @ResponseStatus(HttpStatus.CREATED)
+    public ResponseEntity<News> save(@RequestBody News news, UriComponentsBuilder ucb) {
+        ServiceInstance instance = client.getLocalServiceInstance();
+        logger.info("/news, method: post, host: " + instance.getHost() + ", serviceId: " + instance.getServiceId());
+
+        News saved = newsService.save(news);
+
+        HttpHeaders headers = new HttpHeaders();
+        URI locationUri = ucb.path("/news")
+                .path(String.valueOf(news.getId()))
+                .build()
+                .toUri();
+        headers.setLocation(locationUri);
+
+        ResponseEntity<News> responseEntity = new ResponseEntity<>(saved, headers, HttpStatus.CREATED);
+        return responseEntity;
+    }
+}

+ 23 - 0
src/main/java/com/uas/cloud/mall/shop/news/data/NewsRepository.java

@@ -0,0 +1,23 @@
+package com.uas.cloud.mall.shop.news.data;
+
+import com.uas.cloud.mall.shop.news.model.News;
+import org.springframework.data.jpa.repository.JpaRepository;
+import org.springframework.data.jpa.repository.Query;
+import org.springframework.stereotype.Repository;
+
+import java.util.List;
+
+/**
+ * Created by dongbw on 2017年2月25日 17:56:50.
+ */
+@Repository
+public interface NewsRepository extends JpaRepository<News, Long> {
+
+    @Query(value = "select n from News n where n.module = 'news' order by n.modified DESC")
+    List<News> findByCreated();
+
+    @Query(value = "select n from News n where n.module = 'news' order by n.viewCount DESC")
+    List<News> findByViewCount();
+
+//    List<News> findAllOrderByCreatedDesc(Date date);
+}

+ 164 - 0
src/main/java/com/uas/cloud/mall/shop/news/model/News.java

@@ -0,0 +1,164 @@
+package com.uas.cloud.mall.shop.news.model;
+
+import javax.persistence.*;
+import java.util.*;
+
+/**
+ *  资讯
+ *
+ * Created by dongbw on 17/02/25.
+ */
+
+@Entity
+@Table(name = "jpress_content")
+public class News{
+
+    private static final String INDEX_USOFTCHINA = "10.10.100.88:9090/";
+
+    private static final String NEWS_TEXT = "c/";
+
+    @Id
+    @Column(name = "id")
+    private Long id;
+
+    /**
+     * 标题
+     */
+    @Column(name = "title")
+    private String title;
+
+    /**
+     *  摘要
+     */
+    @Column(name = "summary")
+    private String summary;
+
+    /**
+     *  内容
+     */
+    @Column(name = "text")
+    private String content;
+
+    /**
+     *  缩略图
+     */
+    @Column(name = "thumbnail")
+    private String thumbnail;
+
+    /**
+     *  文章点击量(在官网首页的点击量)
+     */
+    @Column(name = "view_count")
+    private Long viewCount;
+
+    /**
+     *  文章内容页的url后缀
+     *
+     */
+    @Column(name = "slug")
+    private String url_suffix;
+
+    /**
+     *  创建时间
+     */
+    @Column(name = "created")
+    private Date created;
+
+    @Column(name = "module")
+    private String module;
+
+    /**
+     * 最后修改时间
+     *
+     */
+    @Column(name = "modified")
+    private Date modified;
+
+    /**
+     *  链接地址(进入该文章内容)
+     */
+    private String hrefUrl;
+
+    public News() {}
+
+    public News(String title, String summary, String content, String thumbnail, String hrefUrl, Long viewCount, Date created, Date modified , String url_suffix) {
+        this.title = title;
+        this.summary = summary;
+        this.content = content;
+        this.thumbnail = thumbnail;
+        this.hrefUrl = hrefUrl;
+        this.viewCount = viewCount;
+        this.created = created;
+        this.modified = modified;
+        this.url_suffix = url_suffix;
+    }
+
+    public Long getId() {
+        return id;
+    }
+
+    public void setId(Long id) {
+        this.id = id;
+    }
+
+    public String getTitle() {
+        return title;
+    }
+
+    public void setTitle(String title) {
+        this.title = title;
+    }
+
+    public String getSummary() {
+        return summary;
+    }
+
+    public void setSummary(String summary) {
+        this.summary = summary;
+    }
+
+    public String getContent() {
+        return content;
+    }
+
+    public void setContent(String content) {
+        this.content = content;
+    }
+
+    public String getThumbnail() {
+        return thumbnail;
+    }
+
+    public void setThumbnail(String thumbnail) {
+        this.thumbnail = thumbnail;
+    }
+
+    // 跳转到文章详情的URL
+    public String getHrefUrl() {
+        StringBuffer linkTo = new StringBuffer();
+        linkTo.append(INDEX_USOFTCHINA);
+        linkTo.append(NEWS_TEXT);
+        linkTo.append(this.url_suffix);
+        return linkTo.toString();
+    }
+
+    public void setHrefUrl(String hrefUrl) {
+        this.hrefUrl = hrefUrl;
+    }
+
+    public Long getViewCount() {
+        return viewCount;
+    }
+
+    public void setViewCount(Long viewCount) {
+        this.viewCount = viewCount;
+    }
+
+    public Date getCreated() {
+        return created;
+    }
+
+    public void setCreated(Date created) {
+        this.created = created;
+    }
+}

+ 38 - 0
src/main/java/com/uas/cloud/mall/shop/news/service/NewsService.java

@@ -0,0 +1,38 @@
+package com.uas.cloud.mall.shop.news.service;
+
+import com.uas.cloud.mall.shop.news.model.News;
+
+import java.util.Date;
+import java.util.List;
+
+/**
+ * Created by dongbw on 17/02/25 16:05.
+ */
+public interface NewsService {
+
+    News findone(Long id);
+
+    /**
+     *  根据传入数量获取创建时间最新的新闻
+     *
+     * @return
+     */
+    List<News> findBycreated();
+
+    /**
+     *  根据传入数量获取创建时间最新的多条新闻
+     *
+     * @param created
+     * @return
+     */
+    List<News> findBycreatedDesc(Date created);
+
+    /**
+     *  根据传入数量获取点击量最多的多条新闻
+     *
+     * @return
+     */
+    List<News> findByViewCount();
+
+    News save(News news);
+}

+ 47 - 0
src/main/java/com/uas/cloud/mall/shop/news/service/impl/NewsServiceImpl.java

@@ -0,0 +1,47 @@
+package com.uas.cloud.mall.shop.news.service.impl;
+
+import com.uas.cloud.mall.shop.news.data.NewsRepository;
+import com.uas.cloud.mall.shop.news.model.News;
+import com.uas.cloud.mall.shop.news.service.NewsService;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+import java.util.Collections;
+import java.util.Date;
+import java.util.List;
+
+/**
+ * Created by dongbw on 17/02/25 16:05.
+ */
+@Service
+public class NewsServiceImpl implements NewsService {
+
+    @Autowired
+    private NewsRepository newsRepository;
+
+    @Override
+    public News findone(Long id) {
+        return newsRepository.findOne(id);
+    }
+
+    @Override
+    public List<News> findBycreated() {
+        return newsRepository.findByCreated();
+    }
+
+    @Override
+    public List<News> findBycreatedDesc(Date created) {
+        /*return newsRepository.findAllOrderByCreatedDesc(created);*/
+        return Collections.emptyList();
+    }
+
+    @Override
+    public List<News> findByViewCount() {
+        return newsRepository.findByViewCount();
+    }
+
+    @Override
+    public News save(News news) {
+        return newsRepository.save(news);
+    }
+}

+ 27 - 0
src/main/resources/application-dev.yml

@@ -0,0 +1,27 @@
+spring:
+  application:
+    name: news-service
+  jpa:
+#    hibernate:
+#      ddl-auto:
+#        create-drop
+    properties:
+      hibernate:
+        hbm2ddl:
+          auto: update
+        dialect: org.hibernate.dialect.MySQL5Dialect
+    # disable open EntityManager in View
+    open-in-view: false
+  datasource:
+    url: jdbc:mysql://192.168.253.6:3306/dongbw_jpress?useUnicode=true&characterEncoding=utf-8
+    username: usoftchina
+    password: select123***
+    driver-class-name: com.mysql.jdbc.Driver
+
+server:
+  port: 2258
+
+eureka:
+  client:
+    serviceUrl:
+      defaultZone: http://localhost:1111/eureka/

+ 26 - 0
src/main/resources/application-prod.yml

@@ -0,0 +1,26 @@
+spring:
+  application:
+    name: news-service
+  jpa:
+#    hibernate:
+#      ddl-auto:
+#        create-drop
+    properties:
+      hibernate:
+        hbm2ddl:
+          auto: update
+    # disable open EntityManager in View
+    open-in-view: false
+  datasource:
+    url: jdbc:mysql://localhost:3306/shop?useUnicode=true&characterEncoding=utf-8
+    username: root
+    password: mySUN1314
+    driver-class-name: com.mysql.jdbc.Driver
+
+server:
+  port: 2258
+
+eureka:
+  client:
+    serviceUrl:
+      defaultZone: http://localhost:1111/eureka/

+ 5 - 0
src/main/resources/application.yml

@@ -0,0 +1,5 @@
+spring:
+  application:
+    name: news-service
+  profiles:
+    active: dev