nacos | use dynamic service discovery , configuration and service | Microservice library

 by   alibaba Java Version: 2.2.1 License: Apache-2.0

kandi X-RAY | nacos Summary

nacos is a Java library typically used in Architecture, Microservice applications. nacos has no bugs, it has no vulnerabilities, it has build file available, it has a Permissive License and it has medium support. You can download it from GitHub, Maven.
an easy-to-use dynamic service discovery, configuration and service management platform for building cloud native applications.
    Support
      Quality
        Security
          License
            Reuse
            Support
              Quality
                Security
                  License
                    Reuse

                      kandi-support Support

                        summary
                        nacos has a medium active ecosystem.
                        summary
                        It has 25856 star(s) with 11489 fork(s). There are 907 watchers for this library.
                        summary
                        There were 7 major release(s) in the last 6 months.
                        summary
                        There are 227 open issues and 6615 have been closed. On average issues are closed in 5 days. There are 12 open pull requests and 0 closed requests.
                        summary
                        It has a neutral sentiment in the developer community.
                        summary
                        The latest version of nacos is 2.2.1
                        nacos Support
                          Best in #Microservice
                            Average in #Microservice
                            nacos Support
                              Best in #Microservice
                                Average in #Microservice

                                  kandi-Quality Quality

                                    summary
                                    nacos has 0 bugs and 0 code smells.
                                    nacos Quality
                                      Best in #Microservice
                                        Average in #Microservice
                                        nacos Quality
                                          Best in #Microservice
                                            Average in #Microservice

                                              kandi-Security Security

                                                summary
                                                nacos has no vulnerabilities reported, and its dependent libraries have no vulnerabilities reported.
                                                summary
                                                nacos code analysis shows 0 unresolved vulnerabilities.
                                                summary
                                                There are 0 security hotspots that need review.
                                                nacos Security
                                                  Best in #Microservice
                                                    Average in #Microservice
                                                    nacos Security
                                                      Best in #Microservice
                                                        Average in #Microservice

                                                          kandi-License License

                                                            summary
                                                            nacos is licensed under the Apache-2.0 License. This license is Permissive.
                                                            summary
                                                            Permissive licenses have the least restrictions, and you can use them in most projects.
                                                            nacos License
                                                              Best in #Microservice
                                                                Average in #Microservice
                                                                nacos License
                                                                  Best in #Microservice
                                                                    Average in #Microservice

                                                                      kandi-Reuse Reuse

                                                                        summary
                                                                        nacos releases are available to install and integrate.
                                                                        summary
                                                                        Deployable package is available in Maven.
                                                                        summary
                                                                        Build file is available. You can build the component from source.
                                                                        summary
                                                                        Installation instructions, examples and code snippets are available.
                                                                        summary
                                                                        nacos saves you 92978 person hours of effort in developing the same functionality from scratch.
                                                                        summary
                                                                        It has 103434 lines of code, 8355 functions and 1129 files.
                                                                        summary
                                                                        It has medium code complexity. Code complexity directly impacts maintainability of the code.
                                                                        nacos Reuse
                                                                          Best in #Microservice
                                                                            Average in #Microservice
                                                                            nacos Reuse
                                                                              Best in #Microservice
                                                                                Average in #Microservice
                                                                                  Top functions reviewed by kandi - BETA
                                                                                  kandi has reviewed nacos and discovered the below as its top functions. This is intended to give you an instant insight into nacos implemented functionality, and help decide if they suit your requirements.
                                                                                  • Compares two arrays .
                                                                                    • Receive a heartbeat from the master .
                                                                                      • Get the config .
                                                                                        • Gets the context .
                                                                                          • Binary stream observer for request .
                                                                                            • Loads the credential .
                                                                                              • Attempt to match a pattern
                                                                                                • apply rule .
                                                                                                  • Return a page of config info
                                                                                                    • Perform reconnect .
                                                                                                      Get all kandi verified functions for this library.
                                                                                                      Get all kandi verified functions for this library.

                                                                                                      nacos Key Features

                                                                                                      an easy-to-use dynamic service discovery, configuration and service management platform for building cloud native applications.

                                                                                                      nacos Examples and Code Snippets

                                                                                                      No Code Snippets are available at this moment for nacos.
                                                                                                      Community Discussions

                                                                                                      Trending Discussions on nacos

                                                                                                      How to extract kubernetes pod command execution result attributes
                                                                                                      chevron right
                                                                                                      How can i change heap size when i use docker-compose and dockerfile to create a javaproject?
                                                                                                      chevron right
                                                                                                      Error creating bean with name 'projectController': Unsatisfied dependency expressed through field 'service';
                                                                                                      chevron right
                                                                                                      How to find which pom item introduces a specific external dependency?
                                                                                                      chevron right

                                                                                                      QUESTION

                                                                                                      How to extract kubernetes pod command execution result attributes
                                                                                                      Asked 2022-Mar-03 at 16:00

                                                                                                      I am connecting to pod via client-Go and I want to get the properties of the file directory

                                                                                                      func GetPodFiles(c *gin.Context)  {
                                                                                                          client, _ := Init.ClusterID(c)
                                                                                                          path := c.DefaultQuery("path", "/")
                                                                                                          cmd := []string{
                                                                                                              "sh",
                                                                                                              "-c",
                                                                                                              fmt.Sprintf("ls -l %s", path),
                                                                                                          }
                                                                                                          config, _ := Init.ClusterCfg(c)
                                                                                                          req := client.CoreV1().RESTClient().Post().
                                                                                                              Resource("pods").
                                                                                                              Name("nacos-0").
                                                                                                              Namespace("default").SubResource("exec").Param("container", "nacos")
                                                                                                          req.VersionedParams(
                                                                                                              &v1.PodExecOptions{
                                                                                                                  Command: cmd,
                                                                                                                  Stdin:   false,
                                                                                                                  Stdout:  true,
                                                                                                                  Stderr:  true,
                                                                                                                  TTY:     false,
                                                                                                              },
                                                                                                              scheme.ParameterCodec,
                                                                                                          )
                                                                                                      
                                                                                                          var stdout, stderr bytes.Buffer
                                                                                                          exec, err := remotecommand.NewSPDYExecutor(config, "POST", req.URL())
                                                                                                          if err != nil {
                                                                                                              response.FailWithMessage(response.InternalServerError, err.Error(), c)
                                                                                                              return
                                                                                                          }
                                                                                                          err = exec.Stream(remotecommand.StreamOptions{
                                                                                                              Stdin:  nil,
                                                                                                              Stdout: &stdout,
                                                                                                              Stderr: &stderr,
                                                                                                          })
                                                                                                          if err != nil {
                                                                                                              response.FailWithMessage(response.InternalServerError, "Error obtaining file", c)
                                                                                                              return
                                                                                                          }
                                                                                                      
                                                                                                          fmt.Println(stdout.String())
                                                                                                      }
                                                                                                      

                                                                                                      Execution Result Output

                                                                                                      total 0
                                                                                                      lrwxrwxrwx   1 root root   7 Jun  1  2018 bin -> usr/bin
                                                                                                      drwxr-xr-x   5 root root 360 Feb 16 16:39 dev
                                                                                                      lrwxrwxrwx   1 root root   8 Jun  1  2018 sbin -> usr/sbin
                                                                                                      drwxr-xr-x   2 root root   6 Apr 11  2018 srv
                                                                                                      

                                                                                                      Expect the result

                                                                                                      "data": [
                                                                                                              {
                                                                                                                  "perm": "drwxr-xr-x",
                                                                                                                  "mod_time": "2022-03-02 15:02:15",
                                                                                                                  "kind": "d",
                                                                                                                  "name": "temp",
                                                                                                                  "size": ""
                                                                                                              },
                                                                                                      ]
                                                                                                      

                                                                                                      Is there a good way or a golang third-party library to handle it. Please let me know. Thank you

                                                                                                      ANSWER

                                                                                                      Answered 2022-Mar-03 at 16:00

                                                                                                      In a Kubernetes pod you can execute the stat linux command instead of ls command.

                                                                                                      $ stat yourFileOrDirName
                                                                                                      

                                                                                                      The output of this command by default is like this:

                                                                                                        File: yourFileOrDirName
                                                                                                        Size: 346             Blocks: 0          IO Block: 4096   directory
                                                                                                      Device: 51h/82d Inode: 40431       Links: 1
                                                                                                      Access: (0755/drwxr-xr-x)  Uid: ( 1000/ username)   Gid: ( 1000/ groupname)
                                                                                                      Access: 2022-03-02 11:59:07.384821351 +0100
                                                                                                      Modify: 2022-03-02 11:58:48.733821177 +0100
                                                                                                      Change: 2022-03-02 11:58:48.733821177 +0100
                                                                                                       Birth: 2021-12-21 11:12:05.571841723 +0100
                                                                                                      

                                                                                                      But you can tweak its output like this:

                                                                                                      $ stat --printf="%n,%A,%y,%s" yourFileOrDirName
                                                                                                      

                                                                                                      where %n - file name, %A - permission bits and file type in human readable form, %y - time of last data modification human-readable, %s - total size, in bytes. You can also choose any character as a delimiter instead of comma.

                                                                                                      the output will be:

                                                                                                      yourFileOrDirName,drwxr-xr-x,2022-03-02 11:58:48.733821177 +0100,346
                                                                                                      

                                                                                                      See more info about the stat command here.

                                                                                                      After you get such output, I believe you can easily 'convert' it to json format if you really need it.

                                                                                                      Furthermore, you can run the stat command like this:

                                                                                                      $ stat --printf="{\"data\":[{\"name\":\"%n\",\"perm\":\"%A\",\"mod_time\":\"%y\",\"size\":\"%s\"}]}" yourFileOrDirName
                                                                                                      

                                                                                                      Or as @mdaniel suggested, since the command does not contain any shell variables, nor a ', the cleaner command is:

                                                                                                      stat --printf='{"data":[{"name":"%n","perm":"%A","mod_time":"%y","size":"%s"}]}' yourFileOrDirName
                                                                                                      

                                                                                                      and get the DIY json output:

                                                                                                      {"data":[{"name":"yourFileOrDirName","perm":"drwxrwxr-x","mod_time":"2022-02-04 15:17:27.000000000 +0000","size":"4096"}]}
                                                                                                      

                                                                                                      Source https://stackoverflow.com/questions/71331142

                                                                                                      QUESTION

                                                                                                      How can i change heap size when i use docker-compose and dockerfile to create a javaproject?
                                                                                                      Asked 2021-Nov-06 at 14:38

                                                                                                      I wanna use docker-compose to scale heap size when i need, i failed, i need your help, please!!!

                                                                                                      • Dockerfile :
                                                                                                      FROM openjdk:8-jdk
                                                                                                      MAINTAINER whywhathow(whywhathow.fun@gmail.com)
                                                                                                      ENV \
                                                                                                      JVM_GC="UseParallelGC"\
                                                                                                      JVM_XMS="128m" \
                                                                                                      JVM_XMX="256m"  \
                                                                                                      NACOS_ADDR="127.0.0.1:8848" \
                                                                                                      JAVA_OPTS="-Xms${JVM_XMS} -Xmx${JVM_XMX}-XX:+${JVM_GC} -Djava.security.egd=file:/dev/./urandom"\
                                                                                                      PARAMS="--server.port=8080 --spring.profiles.active=prod --spring.cloud.nacos.server-addr=${NACOS_ADDR} --spring.cloud.nacos.config.namespace=prod --spring.cloud.nacos.config.file-extension=yml"
                                                                                                      RUN /bin/cp /usr/share/zoneinfo/Asia/Shanghai /etc/localtime && echo 'Asia/Shanghai' >/etc/timezone
                                                                                                      COPY ./*.jar /app.jar
                                                                                                      #EXPOSE 8080
                                                                                                      ENTRYPOINT ["/bin/sh","-c","java  ${JAVA_OPTS} -jar app.jar ${PARAMS}"]
                                                                                                      
                                                                                                      1. docker-compose.yml
                                                                                                      version: '3'
                                                                                                      services:
                                                                                                        ruoyi-gateway:
                                                                                                          build:
                                                                                                            context: ./service/gateway/
                                                                                                          container_name: ruoyi-gateway
                                                                                                          image: ruoyi-gateway
                                                                                                          ports:
                                                                                                            - "8080:8080"
                                                                                                          environment:
                                                                                                            JVM_XMS: 256m
                                                                                                            JVM_XMX: 256m
                                                                                                            JVM_GC: UseG1GC
                                                                                                      

                                                                                                      so, I believe my config file can work. I'm wrong, I find the problem, error message as list:

                                                                                                             "Mounts": [],
                                                                                                              "Config": {
                                                                                                                  "Hostname": "7a5862c10b9b",
                                                                                                                  "Domainname": "",
                                                                                                                  "User": "",
                                                                                                                  "AttachStdin": false,
                                                                                                                  "AttachStdout": false,
                                                                                                                  "AttachStderr": false,
                                                                                                                  "ExposedPorts": {
                                                                                                                      "8080/tcp": {}
                                                                                                                  },
                                                                                                                  "Tty": false,
                                                                                                                  "OpenStdin": false,
                                                                                                                  "StdinOnce": false,
                                                                                                                  "Env": [
                                                                                                                      "JVM_XMS=256m",
                                                                                                                      "JVM_XMX=256m",
                                                                                                                      "JVM_GC=UseG1GC",
                                                                                                                      "PATH=/usr/local/openjdk-8/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin",
                                                                                                                      "JAVA_HOME=/usr/local/openjdk-8",
                                                                                                                      "LANG=C.UTF-8",
                                                                                                                      "JAVA_VERSION=8u312",
                                                                                                                      "NACOS_ADDR=121.41.120.209:8848",
                                                                                                                      "JAVA_OPTS=-Xms -Xmx-XX:+ -Djava.security.egd=file:/dev/./urandomPARAMS=--server.port=8080 --spring.profiles.active=prod --spring.cloud.nacos.server-addr= --spring.cloud.nacos.config.namespace=prod --spring.cloud.nacos.config.file-extension=yml"
                                                                                                                  ],
                                                                                                                  "Cmd": null,
                                                                                                                  "Image": "ruoyi-gateway",
                                                                                                                  "Volumes": null,
                                                                                                                  "WorkingDir": "",
                                                                                                                  "Entrypoint": [
                                                                                                                      "/bin/sh",
                                                                                                                      "-c",
                                                                                                                      "java  ${JAVA_OPTS} -jar app.jar ${PARAMS}"
                                                                                                                  ],
                                                                                                      

                                                                                                      ANSWER

                                                                                                      Answered 2021-Oct-26 at 11:00

                                                                                                      A Dockerfile ENV directive can only refer to environment variables that are already defined. Without shell hackery, there's no way to define an environment variable that depends on the value some other variable will eventually have.

                                                                                                      For the specific case of the JVM heap size, as of Java 8 update 131, the JVM knows how to see Docker memory limits. As of Java 8 update 190, the default maximum heap size is 25% of available memory, but you can change this, for example

                                                                                                      ENV JAVA_OPTS="-XX:MaxRAMPercentage=75 ..." # but no -Xmx
                                                                                                      

                                                                                                      and use the docker run -m option to set the container memory limit. If you set docker run -m 1g, for example, the JVM heap size will be 768 MiB.

                                                                                                      If that's not an option, I would work around this by setting up the JVM options at execution time. Write a script that sets up $JAVA_OPTS, then runs some command that's passed to it as command-line parameters.

                                                                                                      #!/bin/sh
                                                                                                      # docker-entrypoint.sh
                                                                                                      
                                                                                                      # Set JVM memory options if set as environment variables.
                                                                                                      if [ -n "$JVM_XMS" ]; then
                                                                                                        JAVA_OPTS="$JAVA_OPTS -Xms$JVM_XMS"
                                                                                                      fi
                                                                                                      if [ -n "$JVM_XMX" ]; then
                                                                                                        JAVA_OPTS="$JAVA_OPTS -Xmx$JVM_XMX"
                                                                                                      fi
                                                                                                      
                                                                                                      # Then run the main container command.
                                                                                                      exec "$@"
                                                                                                      

                                                                                                      In the Dockerfile you don't need to set -Xmx in the default JVM options, since the entrypoint script will add it for you. You do need to name this script as the Docker ENTRYPOINT.

                                                                                                      ENV ... \
                                                                                                          JAVA_OPTS="-Djava.security.egd=file:/dev/./urandom" \
                                                                                                          ...
                                                                                                      COPY docker-entrypoint.sh /
                                                                                                      ENTRYPOINT ["/docker-entrypoint.sh"]         # must be JSON array form
                                                                                                      CMD java ${JAVA_OPTS} -jar app.jar ${PARAMS} # Docker inserts `sh -c`
                                                                                                      

                                                                                                      I might also consider using environment variables rather than command-line arguments for the various Spring settings. Spring accepts both, but it's much easier to incrementally set individual environment variables than to try to rewrite the $PARAMS list.

                                                                                                      ENV ... \
                                                                                                          SERVER_PORT=8080 \
                                                                                                          SPRING_PROFILES_ACTIVE=prod \
                                                                                                          ...
                                                                                                      CMD java $JAVA_OPTS -jar app.jar # without $PARAMS
                                                                                                      

                                                                                                      As a final variation, if there are things you need to routinely pass as parameters, it's possible to embed the application call in the entrypoint script. This makes it harder to do things like get a debugging shell (docker run --rm -it your-image bash) but easier to pass parameters without repeating the java command (docker run -d your-image --option). In this setup, you'd end the entrypoint script with the java command, relaying any parameters passed to the script

                                                                                                      exec java $JAVA_OPTS -jar app.jar "$@"
                                                                                                      

                                                                                                      You would not need to mention the java command in the Dockerfile, but you would need to spell out the options in the CMD, which must be JSON-array form (one option to an array item). You cannot use environment variables or other shell substitutions with this setup.

                                                                                                      # if this runs `java -jar app.jar`
                                                                                                      ENTRYPOINT ["/docker-entrypoint.sh"]
                                                                                                      # then include additional options here -- MUST be a JSON array
                                                                                                      CMD ["--server.port=8080", "--spring.profiles.active=prod"]
                                                                                                      

                                                                                                      Source https://stackoverflow.com/questions/69718900

                                                                                                      QUESTION

                                                                                                      Error creating bean with name 'projectController': Unsatisfied dependency expressed through field 'service';
                                                                                                      Asked 2020-Nov-20 at 07:59

                                                                                                      I use the following configuration and code to create a spring boot application.

                                                                                                      pom.xml:

                                                                                                      
                                                                                                      
                                                                                                          
                                                                                                              jeecg-boot-parent
                                                                                                              org.jeecgframework.boot
                                                                                                              2.3.0
                                                                                                          
                                                                                                          4.0.0
                                                                                                          my-pm-project
                                                                                                          
                                                                                                              
                                                                                                                  org.jeecgframework.boot
                                                                                                                  jeecg-system-cloud-api
                                                                                                              
                                                                                                              
                                                                                                                  com.alibaba.cloud
                                                                                                                  spring-cloud-starter-alibaba-nacos-discovery
                                                                                                              
                                                                                                              
                                                                                                                  com.alibaba.cloud
                                                                                                                  spring-cloud-starter-alibaba-sentinel
                                                                                                              
                                                                                                              
                                                                                                                  org.jeecgframework.boot
                                                                                                                  jeecg-boot-base-common
                                                                                                              
                                                                                                              
                                                                                                                  org.springframework.boot
                                                                                                                  spring-boot-starter-data-mongodb
                                                                                                              
                                                                                                          
                                                                                                      
                                                                                                      

                                                                                                      Controller:

                                                                                                      package cn.my.pm.project.controller;
                                                                                                      
                                                                                                      import java.util.Arrays;
                                                                                                      import java.util.List;
                                                                                                      import java.util.Map;
                                                                                                      import java.util.stream.Collectors;
                                                                                                      import java.io.IOException;
                                                                                                      import java.io.UnsupportedEncodingException;
                                                                                                      import java.net.URLDecoder;
                                                                                                      import javax.servlet.http.HttpServletRequest;
                                                                                                      import javax.servlet.http.HttpServletResponse;
                                                                                                      import org.jeecg.common.api.vo.Result;
                                                                                                      import org.jeecg.common.system.query.QueryGenerator;
                                                                                                      import org.jeecg.common.util.oConvertUtils;
                                                                                                      import cn.my.pm.project.entity.Project;
                                                                                                      import cn.my.pm.project.service.IProjectService;
                                                                                                      
                                                                                                      import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
                                                                                                      import com.baomidou.mybatisplus.core.metadata.IPage;
                                                                                                      import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
                                                                                                      import lombok.extern.slf4j.Slf4j;
                                                                                                      import org.jeecg.common.system.base.controller.JeecgController;
                                                                                                      import org.springframework.beans.factory.annotation.Autowired;
                                                                                                      import org.springframework.web.bind.annotation.*;
                                                                                                      import org.springframework.web.multipart.MultipartFile;
                                                                                                      import org.springframework.web.multipart.MultipartHttpServletRequest;
                                                                                                      import org.springframework.web.servlet.ModelAndView;
                                                                                                      import com.alibaba.fastjson.JSON;
                                                                                                      import io.swagger.annotations.Api;
                                                                                                      import io.swagger.annotations.ApiOperation;
                                                                                                      import org.jeecg.common.aspect.annotation.AutoLog;
                                                                                                      
                                                                                                      
                                                                                                      @RestController
                                                                                                      @RequestMapping("/project/project")
                                                                                                      @Slf4j
                                                                                                      public class ProjectController extends JeecgController {
                                                                                                          @Autowired
                                                                                                          private IProjectService projectService;
                                                                                                          
                                                                                                      
                                                                                                          @GetMapping(value = "/list")
                                                                                                          public Result queryPageList(Project project,
                                                                                                                                         @RequestParam(name="pageNo", defaultValue="1") Integer pageNo,
                                                                                                                                         @RequestParam(name="pageSize", defaultValue="10") Integer pageSize,
                                                                                                                                         HttpServletRequest req) {
                                                                                                              QueryWrapper queryWrapper = QueryGenerator.initQueryWrapper(project, req.getParameterMap());
                                                                                                              Page page = new Page(pageNo, pageSize);
                                                                                                              IPage pageList = projectService.page(page, queryWrapper);
                                                                                                              return Result.OK(pageList);
                                                                                                          }
                                                                                                          
                                                                                                      
                                                                                                          @PostMapping(value = "/add")
                                                                                                          public Result add(@RequestBody Project project) {
                                                                                                              projectService.save(project);
                                                                                                              return Result.OK("add!");
                                                                                                          }
                                                                                                          
                                                                                                      
                                                                                                          @PutMapping(value = "/edit")
                                                                                                          public Result edit(@RequestBody Project project) {
                                                                                                              projectService.updateById(project);
                                                                                                              return Result.OK("edit!");
                                                                                                          }
                                                                                                          
                                                                                                      
                                                                                                          @DeleteMapping(value = "/delete")
                                                                                                          public Result delete(@RequestParam(name="id",required=true) String id) {
                                                                                                              projectService.removeById(id);
                                                                                                              return Result.OK("delete!");
                                                                                                          }
                                                                                                          
                                                                                                      
                                                                                                          @DeleteMapping(value = "/deleteBatch")
                                                                                                          public Result deleteBatch(@RequestParam(name="ids",required=true) String ids) {
                                                                                                              this.projectService.removeByIds(Arrays.asList(ids.split(",")));
                                                                                                              return Result.OK("batch delete!");
                                                                                                          }
                                                                                                          
                                                                                                          
                                                                                                          @GetMapping(value = "/queryById")
                                                                                                          public Result queryById(@RequestParam(name="id",required=true) String id) {
                                                                                                              Project project = projectService.getById(id);
                                                                                                              if(project==null) {
                                                                                                                  return Result.error("not found");
                                                                                                              }
                                                                                                              return Result.OK(project);
                                                                                                          }
                                                                                                      
                                                                                                      
                                                                                                      }
                                                                                                      

                                                                                                      Service:

                                                                                                      package cn.my.pm.project.service;
                                                                                                      
                                                                                                      import cn.my.pm.project.entity.Project;
                                                                                                      import com.baomidou.mybatisplus.extension.service.IService;
                                                                                                      
                                                                                                      public interface IProjectService extends IService {
                                                                                                      
                                                                                                      }
                                                                                                      

                                                                                                      ServiceImpl:

                                                                                                      package cn.my.pm.project.service.impl;
                                                                                                      
                                                                                                      import cn.my.pm.project.entity.Project;
                                                                                                      import cn.my.pm.project.mapper.ProjectMapper;
                                                                                                      import cn.my.pm.project.service.IProjectService;
                                                                                                      import lombok.extern.slf4j.Slf4j;
                                                                                                      import org.springframework.stereotype.Service;
                                                                                                      import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
                                                                                                      
                                                                                                      @Service
                                                                                                      @Slf4j
                                                                                                      public class ProjectServiceImpl extends ServiceImpl implements IProjectService {
                                                                                                      
                                                                                                      }
                                                                                                      

                                                                                                      Mapper:

                                                                                                      package cn.my.pm.project.mapper;
                                                                                                      
                                                                                                      import java.util.List;
                                                                                                      import org.apache.ibatis.annotations.Param;
                                                                                                      import cn.my.pm.project.entity.Project;
                                                                                                      import com.baomidou.mybatisplus.core.mapper.BaseMapper;
                                                                                                      import org.springframework.stereotype.Service;
                                                                                                      
                                                                                                      public interface ProjectMapper extends BaseMapper {
                                                                                                      
                                                                                                      }
                                                                                                      

                                                                                                      ProjectMapper.xml:

                                                                                                      
                                                                                                      
                                                                                                      
                                                                                                      
                                                                                                      
                                                                                                      

                                                                                                      Entity:

                                                                                                      package cn.my.pm.project.entity;
                                                                                                      
                                                                                                      import java.io.Serializable;
                                                                                                      import java.io.UnsupportedEncodingException;
                                                                                                      import java.util.Date;
                                                                                                      import java.math.BigDecimal;
                                                                                                      import com.baomidou.mybatisplus.annotation.IdType;
                                                                                                      import com.baomidou.mybatisplus.annotation.TableId;
                                                                                                      import com.baomidou.mybatisplus.annotation.TableName;
                                                                                                      import lombok.Data;
                                                                                                      import com.fasterxml.jackson.annotation.JsonFormat;
                                                                                                      import org.springframework.format.annotation.DateTimeFormat;
                                                                                                      import org.jeecgframework.poi.excel.annotation.Excel;
                                                                                                      import org.jeecg.common.aspect.annotation.Dict;
                                                                                                      import io.swagger.annotations.ApiModel;
                                                                                                      import io.swagger.annotations.ApiModelProperty;
                                                                                                      import lombok.EqualsAndHashCode;
                                                                                                      import lombok.experimental.Accessors;
                                                                                                      
                                                                                                      @Data
                                                                                                      @TableName("my_info")
                                                                                                      
                                                                                                      public class Project implements Serializable {
                                                                                                          private static final long serialVersionUID = 1L;
                                                                                                          private java.lang.String id;
                                                                                                          private java.lang.String myName;
                                                                                                          private java.lang.String myType;
                                                                                                          private java.lang.String myType;
                                                                                                          private java.lang.String myManager;
                                                                                                          private java.lang.String myInfo;
                                                                                                          private java.lang.String myDetails;
                                                                                                          private java.lang.String myImage;
                                                                                                      
                                                                                                      }
                                                                                                      

                                                                                                      Application:

                                                                                                      package cn.my;
                                                                                                      
                                                                                                      import org.apache.shiro.spring.boot.autoconfigure.ShiroAnnotationProcessorAutoConfiguration;
                                                                                                      import org.apache.shiro.spring.boot.autoconfigure.ShiroAutoConfiguration;
                                                                                                      import org.apache.shiro.spring.boot.autoconfigure.ShiroBeanAutoConfiguration;
                                                                                                      import org.springframework.boot.SpringApplication;
                                                                                                      import org.springframework.boot.autoconfigure.SpringBootApplication;
                                                                                                      import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
                                                                                                      import org.springframework.cloud.openfeign.EnableFeignClients;
                                                                                                      
                                                                                                      @SpringBootApplication(exclude = {ShiroAnnotationProcessorAutoConfiguration.class, ShiroAutoConfiguration.class, ShiroBeanAutoConfiguration.class})
                                                                                                      @EnableDiscoveryClient
                                                                                                      @EnableFeignClients
                                                                                                      public class ProjectApplication {
                                                                                                      
                                                                                                          public static void main(String[] args) {
                                                                                                              SpringApplication.run(ProjectApplication.class, args);
                                                                                                          }
                                                                                                      }
                                                                                                      

                                                                                                      But when I run the application,the error message is:

                                                                                                      ERROR org.springframework.boot.SpringApplication:858 - Application run failed
                                                                                                      org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'projectController': Unsatisfied dependency expressed through field 'service'; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'projectServiceImpl': Unsatisfied dependency expressed through field 'baseMapper'; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type 'cn.my.pm.project.mapper.ProjectMapper' available: expected at least 1 bean which qualifies as autowire candidate. Dependency annotations: {@org.springframework.beans.factory.annotation.Autowired(required=true)}
                                                                                                          at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:596)
                                                                                                          at org.springframework.beans.factory.annotation.InjectionMetadata.inject(InjectionMetadata.java:90)
                                                                                                          at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessProperties(AutowiredAnnotationBeanPostProcessor.java:374)
                                                                                                          at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1395)
                                                                                                          at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:592)
                                                                                                          at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:515)
                                                                                                          at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:320)
                                                                                                          at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222)
                                                                                                          at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:318)
                                                                                                          at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:199)
                                                                                                          at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:849)
                                                                                                          at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:877)
                                                                                                          at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:549)
                                                                                                          at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:142)
                                                                                                          at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:775)
                                                                                                          at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:397)
                                                                                                          at org.springframework.boot.SpringApplication.run(SpringApplication.java:316)
                                                                                                          at org.springframework.boot.SpringApplication.run(SpringApplication.java:1260)
                                                                                                          at org.springframework.boot.SpringApplication.run(SpringApplication.java:1248)
                                                                                                          at cn.my.ProjectApplication.main(ProjectApplication.java:18)
                                                                                                      Caused by: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'projectServiceImpl': Unsatisfied dependency expressed through field 'baseMapper'; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type 'cn.my.pm.project.mapper.ProjectMapper' available: expected at least 1 bean which qualifies as autowire candidate. Dependency annotations: {@org.springframework.beans.factory.annotation.Autowired(required=true)}
                                                                                                          at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:596)
                                                                                                          at org.springframework.beans.factory.annotation.InjectionMetadata.inject(InjectionMetadata.java:90)
                                                                                                          at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessProperties(AutowiredAnnotationBeanPostProcessor.java:374)
                                                                                                          at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1395)
                                                                                                          at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:592)
                                                                                                          at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:515)
                                                                                                          at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:320)
                                                                                                          at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222)
                                                                                                          at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:318)
                                                                                                          at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:199)
                                                                                                          at org.springframework.beans.factory.config.DependencyDescriptor.resolveCandidate(DependencyDescriptor.java:277)
                                                                                                          at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:1247)
                                                                                                          at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:1167)
                                                                                                          at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:593)
                                                                                                          ... 19 common frames omitted
                                                                                                      Caused by: org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type 'cn.my.pm.project.mapper.ProjectMapper' available: expected at least 1 bean which qualifies as autowire candidate. Dependency annotations: {@org.springframework.beans.factory.annotation.Autowired(required=true)}
                                                                                                          at org.springframework.beans.factory.support.DefaultListableBeanFactory.raiseNoMatchingBeanFound(DefaultListableBeanFactory.java:1654)
                                                                                                          at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:1213)
                                                                                                          at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:1167)
                                                                                                          at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:593)
                                                                                                          ... 32 common frames omitted
                                                                                                      Disconnected from the target VM, address: '127.0.0.1:64977', transport: 'socket'
                                                                                                      

                                                                                                      How to fix it?

                                                                                                      ANSWER

                                                                                                      Answered 2020-Nov-18 at 06:08

                                                                                                      Spring's complaint is that you haven't defined a Bean of type ProjectMapper, which it is saying that it needs to satisfy an Autowire request. Looking at your code, I don't see a definition for such a Bean in what you've shown us here.

                                                                                                      The exact point of the problem is hidden, I'm guessing, because you aren't showing us the definition of the ServiceImpl class. My guess is that that's where the actual reference is that Spring is trying to wire up. Apparently, the field name is baseMapper.

                                                                                                      Source https://stackoverflow.com/questions/64887470

                                                                                                      QUESTION

                                                                                                      How to find which pom item introduces a specific external dependency?
                                                                                                      Asked 2020-Mar-30 at 08:21

                                                                                                      I want to find which pom item imports the following nacos-api:1.0.0

                                                                                                      I thought it is this item which depends on it

                                                                                                      but the details of it is as below:

                                                                                                      so it is probably not? are there any ways to find which pom item introduces a specific external dependency, especially on IDEA?

                                                                                                      maven tree doesn't help

                                                                                                          mvn dependency:tree -Dincludes=nacos-client:1.0.0
                                                                                                          [INFO] Scanning for projects...
                                                                                                          [INFO]                                                                 
                                                                                                          [INFO] ------------------------------------------------------------------------
                                                                                                          [INFO] Building user 0.0.1-SNAPSHOT
                                                                                                          [INFO] ------------------------------------------------------------------------
                                                                                                          [INFO]
                                                                                                          [INFO] --- maven-dependency-plugin:3.0.1:tree (default-cli) @ user ---
                                                                                                          [INFO] ------------------------------------------------------------------------
                                                                                                          [INFO] BUILD SUCCESS
                                                                                                          [INFO] ------------------------------------------------------------------------
                                                                                                          [INFO] Total time: 2.172 s
                                                                                                          [INFO] Finished at: 2020-03-30T03:06:07+08:00
                                                                                                          [INFO] Final Memory: 37M/361M
                                                                                                          [INFO] ------------------------------------------------------------------------
                                                                                                      

                                                                                                      ANSWER

                                                                                                      Answered 2020-Mar-30 at 08:21

                                                                                                      There is no such single action. But it is possible to find the corresponding for the library pom with these steps:

                                                                                                      1. F4 (Go to source action) on selected item in External library will open this library configuration dialog:

                                                                                                      1. Then use Alt+F7 (Find usages action) to show the module where this library is used:

                                                                                                      1. Then you can find this module in Maven tool window (use speed search for example to locate it more easily), select it in the tree and navigate to corresponding pom using F4 (Go to source action) again:

                                                                                                      Source https://stackoverflow.com/questions/60916973

                                                                                                      Community Discussions, Code Snippets contain sources that include Stack Exchange Network

                                                                                                      Vulnerabilities

                                                                                                      No vulnerabilities reported

                                                                                                      Install nacos

                                                                                                      It is super easy to get started with your first project.
                                                                                                      Quick start with Nacos command and console
                                                                                                      Quick start with dubbo
                                                                                                      Quick start with spring cloud
                                                                                                      Quick start with kubernetes
                                                                                                      Github Release
                                                                                                      Baidu Netdisk Fetch Code : rest

                                                                                                      Support

                                                                                                      You can view the full documentation from the Nacos website. All the latest and long-term notice can also be found here from Github notice issue.
                                                                                                      Find more information at:
                                                                                                      Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
                                                                                                      Find more libraries
                                                                                                      Explore Kits - Develop, implement, customize Projects, Custom Functions and Applications with kandi kits​
                                                                                                      Save this library and start creating your kit

                                                                                                      Share this Page

                                                                                                      share link

                                                                                                      Explore Related Topics

                                                                                                      Consider Popular Microservice Libraries

                                                                                                      mall

                                                                                                      by macrozheng

                                                                                                      istio

                                                                                                      by istio

                                                                                                      apollo

                                                                                                      by apolloconfig

                                                                                                      Try Top Libraries by alibaba

                                                                                                      arthas

                                                                                                      by alibabaJava

                                                                                                      p3c

                                                                                                      by alibabaKotlin

                                                                                                      easyexcel

                                                                                                      by alibabaJava

                                                                                                      druid

                                                                                                      by alibabaJava

                                                                                                      canal

                                                                                                      by alibabaJava

                                                                                                      Compare Microservice Libraries with Highest Support

                                                                                                      apollo

                                                                                                      by ctripcorp

                                                                                                      istio

                                                                                                      by istio

                                                                                                      open-liberty

                                                                                                      by OpenLiberty

                                                                                                      envoy

                                                                                                      by envoyproxy

                                                                                                      seata

                                                                                                      by seata

                                                                                                      Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
                                                                                                      Find more libraries
                                                                                                      Explore Kits - Develop, implement, customize Projects, Custom Functions and Applications with kandi kits​
                                                                                                      Save this library and start creating your kit