找不到springboot Crudepository

kokeuurv  于 2021-07-13  发布在  Java
关注(0)|答案(2)|浏览(544)

我对springboot还不熟悉,只是在用它做一个学习项目。我把地狱世界搞定了,正在进入数据库。我在示例的基础上添加了一个repository类,并获得以下内容。这是基于搜索很多人得到的。问题是我所看到的解决方案并不能解决我的问题。我的存储库位于主类的子包中。我现在有一个“数据”和“控制器”子包。我试过一些建议,但似乎没有一个能解决我的问题。相关消息来源如下。

Description:

Field assets in mypkg.microsvc.controller.AssetController required a bean of type 'mypkg.microsvc.data.AssetRepository' that could not be found.

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

Action:

Consider defining a bean of type 'mypkg.microsvc.data.AssetRepository' in your configuration.

实体(注意我有一个@entity注解)

package mypkg.microsvc.data;
import javax.persistence.Entity;
[...]
@Entity
@Table(name = "ASSET_T", schema = "K702PRDR")
public class Asset implements java.io.Serializable  { 
  private static final long serialVersionUID = -4631085917731566134L;

  @Id
  @Column(name = "ASSET_ID", unique = true, nullable = false)
  private String assetId;
[...]

repository接口(我尝试过使用和不使用注解,扩展crudrepository和jparepository)

package mypkg.microsvc.data;

import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.repository.CrudRepository;
import org.springframework.stereotype.Repository;
[...]

@Repository
public interface AssetRepository extends JpaRepository<Asset, String> {
  public List<Asset> findAll();
}

应用程序对象(我尝试了许多不同的注解,试图让它扫描并查看我的存储库,如您所见……这甚至不是所有的迭代。据我所知,鉴于我的app对象位于包层次结构中的存储库之上,我应该只需要@springbootapplication注解。但我想证明,我已经尝试了所有这些事情,我得到了同样的结果。)

package mypkg.microsvc;
[...]
@SpringBootApplication(scanBasePackages={
    "mypkg.microsvc", 
    "mypkg.microsvc.controller", 
    "mypkg.microsvc.data"})
//@EnableJpaRepositories("mypkg.microsvc.data")
//@EntityScan("mypkg.microsvc.data")
@ComponentScan(basePackages={
    "mypkg.microsvc", 
    "mypkg.microsvc.controller", 
    "mypkg.microsvc.data"})
public class MicroApplication {
  public static void main(String[] args) throws Exception {
    SpringApplication.run(MicroApplication.class, args);
}
}

这是我的控制器。我又经历了几次迭代

package mypkg.microsvc.controller;

 [...]
 import mypkg.microsvc.data.Asset;
 import mypkg.microsvc.data.AssetRepository;

 @RestController
 @EnableAutoConfiguration
 public class AssetController {
   @Autowired
   AssetRepository assets;

   @RequestMapping(value="/list", method=RequestMethod.GET, produces=MediaType.APPLICATION_JSON_VALUE)
   public @ResponseBody List<Asset> list() {
     return assets.findAll();
   }
}

我的印象是,这是它应该采取的一切。我在哪里搞砸了?
更新(打开跟踪时添加跟踪):

2021-04-08 15:36:41.593 DEBUG 17920 --- [           main] o.a.catalina.core.AprLifecycleListener   : The Apache Tomcat Native library could not be found using names [tcnative-1, libtcnative-1] on the java.library.path [C:\DevApps\IBM\WebSphere\AppServerV9\java\8.0\jre\bin\compressedrefs;C:\DevApps\IBM\WebSphere\AppServerV9\java\8.0\jre\bin;C:\WINDOWS\system32;C:\WINDOWS;C:\DevApps\IBM\WebSphere\AppServerV9\java\8.0\jre\bin;C:\Program Files\Amazon Corretto\jdk1.8.0_252\bin;C:\Program Files (x86)\Business Objects\Common\3.5\bin\NOTES\;C:\Program Files (x86)\Business Objects\Common\3.5\bin\NOTES\DATA\;C:\ProgramData\Oracle\Java\javapath;C:\Program Files (x86)\ibm\RationalSDLC\common;C:\Windows\System32;C:\Windows;C:\Windows\System32\wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Program Files (x86)\ibm\RationalSDLC\ClearCase\bin;C:\Program Files (x86)\ibm\gsk8\lib;C:\Program Files (x86)\ibm\gsk8\bin;C:\Program Files (x86)\ibm\RationalSDLC\ClearCase\RemoteClient\cteapis;C:\Program Files (x86)\HID Global\ActivClient\;C:\Program Files\HID Global\ActivClient\;C:\PROGRA~1\IBM\SQLLIB\BIN;C:\PROGRA~1\IBM\SQLLIB\FUNCTION;C:\PROGRA~1\IBM\SQLLIB\SAMPLES\REPL;C:\Program Files (x86)\IBM\gsk8\lib;C:\Program Files (x86)\IBM\gsk8\bin;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\WINDOWS\System32\WindowsPowerShell\v1.0\;C:\WINDOWS\System32\OpenSSH\;C:\Users\bmulholl\AppData\Local\Microsoft\WindowsApps;;.]. The errors reported were [C:\views\CATS_Development\CATS_SW\SpringBootMicroTest\bin\tcnative-1.dll (The specified module could not be found. ), C:\views\CATS_Development\CATS_SW\SpringBootMicroTest\bin\libtcnative-1.dll (The specified module could not be found. ), tcnative-1 (Not found in java.library.path), libtcnative-1 (Not found in java.library.path)]

org.apache.tomcat.jni.LibraryNotFoundError: C:\views\CATS_Development\CATS_SW\SpringBootMicroTest\bin\tcnative-1.dll (The specified module could not be found. ), C:\views\CATS_Development\CATS_SW\SpringBootMicroTest\bin\libtcnative-1.dll (The specified module could not be found. ), tcnative-1 (Not found in java.library.path), libtcnative-1 (Not found in java.library.path)
    at org.apache.tomcat.jni.Library.<init>(Library.java:102) ~[tomcat-embed-core-9.0.44.jar:9.0.44]
    at org.apache.tomcat.jni.Library.initialize(Library.java:206) ~[tomcat-embed-core-9.0.44.jar:9.0.44]
    at org.apache.catalina.core.AprLifecycleListener.init(AprLifecycleListener.java:193) [tomcat-embed-core-9.0.44.jar:9.0.44]
    at org.apache.catalina.core.AprLifecycleListener.isAprAvailable(AprLifecycleListener.java:102) [tomcat-embed-core-9.0.44.jar:9.0.44]
    at org.springframework.boot.web.embedded.tomcat.TomcatServletWebServerFactory.getDefaultLifecycleListeners(TomcatServletWebServerFactory.java:173) [spring-boot-2.4.4.jar:2.4.4]
    at org.springframework.boot.web.embedded.tomcat.TomcatServletWebServerFactory.<init>(TomcatServletWebServerFactory.java:120) [spring-boot-2.4.4.jar:2.4.4]
    at org.springframework.boot.autoconfigure.web.servlet.ServletWebServerFactoryConfiguration$EmbeddedTomcat.tomcatServletWebServerFactory(ServletWebServerFactoryConfiguration.java:76) [spring-boot-autoconfigure-2.4.4.jar:2.4.4]
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.8.0]
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:90) ~[na:1.8.0]
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:55) ~[na:1.8.0]
    at java.lang.reflect.Method.invoke(Method.java:508) ~[na:1.8.0]
    at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:154) [spring-beans-5.3.5.jar:5.3.5]
    at org.springframework.beans.factory.support.ConstructorResolver.instantiate(ConstructorResolver.java:653) [spring-beans-5.3.5.jar:5.3.5]
    at org.springframework.beans.factory.support.ConstructorResolver.instantiateUsingFactoryMethod(ConstructorResolver.java:638) [spring-beans-5.3.5.jar:5.3.5]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateUsingFactoryMethod(AbstractAutowireCapableBeanFactory.java:1334) [spring-beans-5.3.5.jar:5.3.5]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1177) [spring-beans-5.3.5.jar:5.3.5]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:564) [spring-beans-5.3.5.jar:5.3.5]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:524) [spring-beans-5.3.5.jar:5.3.5]
    at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:335) [spring-beans-5.3.5.jar:5.3.5]
    at org.springframework.beans.factory.support.AbstractBeanFactory$$Lambda$222/000000001247BD90.getObject(Unknown Source) [spring-beans-5.3.5.jar:5.3.5]
    at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:234) [spring-beans-5.3.5.jar:5.3.5]
    at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:333) [spring-beans-5.3.5.jar:5.3.5]
    at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:213) [spring-beans-5.3.5.jar:5.3.5]
    at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.getWebServerFactory(ServletWebServerApplicationContext.java:216) [spring-boot-2.4.4.jar:2.4.4]
    at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.createWebServer(ServletWebServerApplicationContext.java:179) [spring-boot-2.4.4.jar:2.4.4]
    at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.onRefresh(ServletWebServerApplicationContext.java:159) [spring-boot-2.4.4.jar:2.4.4]
    at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:577) [spring-context-5.3.5.jar:5.3.5]
    at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:144) [spring-boot-2.4.4.jar:2.4.4]
    at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:769) [spring-boot-2.4.4.jar:2.4.4]
    at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:761) [spring-boot-2.4.4.jar:2.4.4]
    at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:426) [spring-boot-2.4.4.jar:2.4.4]
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:326) [spring-boot-2.4.4.jar:2.4.4]
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:1313) [spring-boot-2.4.4.jar:2.4.4]
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:1302) [spring-boot-2.4.4.jar:2.4.4]
    at gov.usdoj.afms.microsvc.MicroApplication.main(MicroApplication.java:19) [bin/:na]

2021-04-08 15:36:42.064 DEBUG 17920 --- [           main] o.apache.tomcat.util.compat.Jre9Compat   : Class not found so assuming code is running on a pre-Java 9 JVM

java.lang.ClassNotFoundException: java.lang.reflect.InaccessibleObjectException
    at java.lang.Class.forNameImpl(Native Method) ~[na:2.9 (04-02-2020)]
    at java.lang.Class.forName(Class.java:337) ~[na:2.9 (04-02-2020)]
    at org.apache.tomcat.util.compat.Jre9Compat.<clinit>(Jre9Compat.java:83) ~[tomcat-embed-core-9.0.44.jar:9.0.44]
    at org.apache.tomcat.util.compat.JreCompat.<clinit>(JreCompat.java:70) [tomcat-embed-core-9.0.44.jar:9.0.44]
    at org.apache.catalina.startup.Tomcat.<clinit>(Tomcat.java:1303) [tomcat-embed-core-9.0.44.jar:9.0.44]
    at org.springframework.boot.web.embedded.tomcat.TomcatServletWebServerFactory.getWebServer(TomcatServletWebServerFactory.java:185) [spring-boot-2.4.4.jar:2.4.4]
    at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.createWebServer(ServletWebServerApplicationContext.java:181) [spring-boot-2.4.4.jar:2.4.4]
    at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.onRefresh(ServletWebServerApplicationContext.java:159) [spring-boot-2.4.4.jar:2.4.4]
    at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:577) [spring-context-5.3.5.jar:5.3.5]
    at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:144) [spring-boot-2.4.4.jar:2.4.4]
    at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:769) [spring-boot-2.4.4.jar:2.4.4]
    at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:761) [spring-boot-2.4.4.jar:2.4.4]
    at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:426) [spring-boot-2.4.4.jar:2.4.4]
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:326) [spring-boot-2.4.4.jar:2.4.4]
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:1313) [spring-boot-2.4.4.jar:2.4.4]
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:1302) [spring-boot-2.4.4.jar:2.4.4]
    at gov.usdoj.afms.microsvc.MicroApplication.main(MicroApplication.java:19) [bin/:na]

2021-04-08 15:36:42.067 DEBUG 17920 --- [           main] o.apache.tomcat.util.compat.Jre16Compat  : Class not found so assuming code is running on a pre-Java 16 JVM

java.lang.ClassNotFoundException: java.net.UnixDomainSocketAddress
    at java.lang.Class.forNameImpl(Native Method) ~[na:2.9 (04-02-2020)]
    at java.lang.Class.forName(Class.java:337) ~[na:2.9 (04-02-2020)]
    at org.apache.tomcat.util.compat.Jre16Compat.<clinit>(Jre16Compat.java:47) ~[tomcat-embed-core-9.0.44.jar:9.0.44]
    at org.apache.tomcat.util.compat.JreCompat.<clinit>(JreCompat.java:70) [tomcat-embed-core-9.0.44.jar:9.0.44]
    at org.apache.catalina.startup.Tomcat.<clinit>(Tomcat.java:1303) [tomcat-embed-core-9.0.44.jar:9.0.44]
    at org.springframework.boot.web.embedded.tomcat.TomcatServletWebServerFactory.getWebServer(TomcatServletWebServerFactory.java:185) [spring-boot-2.4.4.jar:2.4.4]
    at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.createWebServer(ServletWebServerApplicationContext.java:181) [spring-boot-2.4.4.jar:2.4.4]
    at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.onRefresh(ServletWebServerApplicationContext.java:159) [spring-boot-2.4.4.jar:2.4.4]
    at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:577) [spring-context-5.3.5.jar:5.3.5]
    at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:144) [spring-boot-2.4.4.jar:2.4.4]
    at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:769) [spring-boot-2.4.4.jar:2.4.4]
    at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:761) [spring-boot-2.4.4.jar:2.4.4]
    at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:426) [spring-boot-2.4.4.jar:2.4.4]
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:326) [spring-boot-2.4.4.jar:2.4.4]
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:1313) [spring-boot-2.4.4.jar:2.4.4]
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:1302) [spring-boot-2.4.4.jar:2.4.4]
    at gov.usdoj.afms.microsvc.MicroApplication.main(MicroApplication.java:19) [bin/:na]

2021-04-08 15:36:42.841 DEBUG 17920 --- [           main] o.apache.tomcat.util.IntrospectionUtils  : IntrospectionUtils: setProperty(class org.apache.coyote.http11.Http11NioProtocol port=8080)
2021-04-08 15:36:42.862 DEBUG 17920 --- [           main] o.apache.tomcat.util.IntrospectionUtils  : IntrospectionUtils: setProperty(class org.apache.coyote.http11.Http11NioProtocol bindOnInit=false)
2021-04-08 15:36:42.863 DEBUG 17920 --- [           main] org.apache.tomcat.util.net.NioEndpoint   : Set [bindOnInit] to [false]
2021-04-08 15:36:42.864 DEBUG 17920 --- [           main] o.apache.tomcat.util.IntrospectionUtils  : IntrospectionUtils: setProperty(class org.apache.tomcat.util.net.NioEndpoint bindOnInit=false)
2021-04-08 15:36:42.867 DEBUG 17920 --- [           main] o.apache.tomcat.util.IntrospectionUtils  : IntrospectionUtils: setProperty(class org.apache.coyote.http11.Http11NioProtocol maxPostSize=2097152)
2021-04-08 15:36:42.868 DEBUG 17920 --- [           main] org.apache.tomcat.util.net.NioEndpoint   : Set [maxPostSize] to [2097152]
2021-04-08 15:36:42.869 DEBUG 17920 --- [           main] o.apache.tomcat.util.IntrospectionUtils  : IntrospectionUtils: setProperty(class org.apache.tomcat.util.net.NioEndpoint maxPostSize=2097152)
2021-04-08 15:36:42.924 DEBUG 17920 --- [           main] org.apache.catalina.core.ContainerBase   : Add child StandardHost[localhost] StandardEngine[Tomcat]
2021-04-08 15:36:42.995 DEBUG 17920 --- [           main] org.apache.catalina.core.ContainerBase   : Add child TomcatEmbeddedContext[] StandardEngine[Tomcat].StandardHost[localhost]
2021-04-08 15:36:43.019 DEBUG 17920 --- [           main] o.apache.tomcat.util.IntrospectionUtils  : IntrospectionUtils: setProperty(class org.apache.coyote.http11.Http11NioProtocol parseBodyMethods=POST)
2021-04-08 15:36:43.020 DEBUG 17920 --- [           main] org.apache.tomcat.util.net.NioEndpoint   : Set [parseBodyMethods] to [POST]
2021-04-08 15:36:43.020 DEBUG 17920 --- [           main] o.apache.tomcat.util.IntrospectionUtils  : IntrospectionUtils: setProperty(class org.apache.tomcat.util.net.NioEndpoint parseBodyMethods=POST)
2021-04-08 15:36:43.021  INFO 17920 --- [           main] o.apache.catalina.core.StandardService   : Starting service [Tomcat]
2021-04-08 15:36:43.023  INFO 17920 --- [           main] org.apache.catalina.core.StandardEngine  : Starting Servlet engine: [Apache Tomcat/9.0.44]
2021-04-08 15:36:43.026 DEBUG 17920 --- [           main] o.apache.catalina.core.StandardContext   : Starting ROOT
2021-04-08 15:36:43.055 DEBUG 17920 --- [           main] o.apache.catalina.core.StandardContext   : Configuring default Resources
2021-04-08 15:36:43.288 DEBUG 17920 --- [           main] o.apache.catalina.core.StandardContext   : Processing standard container startup
2021-04-08 15:36:43.289 DEBUG 17920 --- [           main] org.apache.catalina.loader.WebappLoader  : Starting this Loader
2021-04-08 15:36:43.298 DEBUG 17920 --- [           main] o.apache.tomcat.util.IntrospectionUtils  : IntrospectionUtils: setProperty(class org.springframework.boot.web.embedded.tomcat.TomcatEmbeddedWebappClassLoader clearReferencesRmiTargets=false)
2021-04-08 15:36:43.299 DEBUG 17920 --- [           main] o.apache.tomcat.util.IntrospectionUtils  : IntrospectionUtils: setProperty(class org.springframework.boot.web.embedded.tomcat.TomcatEmbeddedWebappClassLoader clearReferencesStopThreads=false)
2021-04-08 15:36:43.300 DEBUG 17920 --- [           main] o.apache.tomcat.util.IntrospectionUtils  : IntrospectionUtils: setProperty(class org.springframework.boot.web.embedded.tomcat.TomcatEmbeddedWebappClassLoader clearReferencesStopTimerThreads=false)
2021-04-08 15:36:43.300 DEBUG 17920 --- [           main] o.apache.tomcat.util.IntrospectionUtils  : IntrospectionUtils: setProperty(class org.springframework.boot.web.embedded.tomcat.TomcatEmbeddedWebappClassLoader clearReferencesHttpClientKeepAliveThread=true)
2021-04-08 15:36:43.301 DEBUG 17920 --- [           main] o.apache.tomcat.util.IntrospectionUtils  : IntrospectionUtils: setProperty(class org.springframework.boot.web.embedded.tomcat.TomcatEmbeddedWebappClassLoader clearReferencesObjectStreamClassCaches=false)
2021-04-08 15:36:43.301 DEBUG 17920 --- [           main] o.apache.tomcat.util.IntrospectionUtils  : IntrospectionUtils: setProperty(class org.springframework.boot.web.embedded.tomcat.TomcatEmbeddedWebappClassLoader clearReferencesObjectStreamClassCaches=false)
2021-04-08 15:36:43.302 DEBUG 17920 --- [           main] o.apache.tomcat.util.IntrospectionUtils  : IntrospectionUtils: setProperty(class org.springframework.boot.web.embedded.tomcat.TomcatEmbeddedWebappClassLoader clearReferencesThreadLocals=false)
2021-04-08 15:36:43.346 DEBUG 17920 --- [           main] o.a.c.authenticator.AuthenticatorBase    : No SingleSignOn Valve is present
2021-04-08 15:36:43.347 DEBUG 17920 --- [           main] o.apache.catalina.core.StandardContext   : No manager found. Checking if cluster manager should be used. Cluster configured: [false], Application distributable: [false]
2021-04-08 15:36:43.353 DEBUG 17920 --- [           main] o.apache.catalina.core.StandardContext   : Configured a manager of class [org.apache.catalina.session.StandardManager]
2021-04-08 15:36:43.361  INFO 17920 --- [           main] o.a.c.c.C.[Tomcat].[localhost].[/]       : Initializing Spring embedded WebApplicationContext
2021-04-08 15:36:43.448 DEBUG 17920 --- [           main] org.apache.catalina.core.ContainerBase   : Add child StandardWrapper[dispatcherServlet] StandardEngine[Tomcat].StandardHost[localhost].TomcatEmbeddedContext[]
2021-04-08 15:36:43.483 DEBUG 17920 --- [           main] o.apache.catalina.core.StandardContext   : Configuring application event listeners
2021-04-08 15:36:43.484 DEBUG 17920 --- [           main] o.a.c.c.C.[Tomcat].[localhost].[/]       : Sending application start events
2021-04-08 15:36:43.487 DEBUG 17920 --- [           main] o.a.catalina.session.StandardManager     : Start: Loading persisted sessions
2021-04-08 15:36:43.488 DEBUG 17920 --- [           main] o.a.catalina.session.StandardManager     : Loading persisted sessions from [SESSIONS.ser]
2021-04-08 15:36:43.488 DEBUG 17920 --- [           main] o.a.catalina.session.StandardManager     : No persisted data file found
2021-04-08 15:36:43.489 DEBUG 17920 --- [           main] o.a.c.c.C.[Tomcat].[localhost].[/]       : Starting filters
2021-04-08 15:36:43.489 DEBUG 17920 --- [           main] o.a.c.c.C.[Tomcat].[localhost].[/]       :  Starting filter 'requestContextFilter'
2021-04-08 15:36:43.503 DEBUG 17920 --- [           main] o.a.c.c.C.[Tomcat].[localhost].[/]       :  Starting filter 'Tomcat WebSocket (JSR356) Filter'
2021-04-08 15:36:43.504 DEBUG 17920 --- [           main] o.a.c.c.C.[Tomcat].[localhost].[/]       :  Starting filter 'characterEncodingFilter'
2021-04-08 15:36:43.504 DEBUG 17920 --- [           main] o.a.c.c.C.[Tomcat].[localhost].[/]       :  Starting filter 'formContentFilter'
2021-04-08 15:36:43.505 DEBUG 17920 --- [           main] o.apache.catalina.core.StandardContext   : Starting completed
2021-04-08 15:36:43.512 DEBUG 17920 --- [           main] org.apache.catalina.mapper.Mapper        : Registered host [localhost]
2021-04-08 15:36:43.513 DEBUG 17920 --- [           main] o.apache.catalina.mapper.MapperListener  : Register Wrapper [dispatcherServlet] in Context [] for service [StandardService[Tomcat]]
2021-04-08 15:36:43.513 DEBUG 17920 --- [           main] o.apache.catalina.mapper.MapperListener  : Register Context [] for service [StandardService[Tomcat]]
2021-04-08 15:36:43.514 DEBUG 17920 --- [           main] o.apache.catalina.mapper.MapperListener  : Register host [localhost] at domain [null] for service [StandardService[Tomcat]]
2021-04-08 15:36:43.622  INFO 17920 --- [           main] o.apache.catalina.core.StandardService   : Stopping service [Tomcat]
2021-04-08 15:36:43.624 DEBUG 17920 --- [           main] o.apache.catalina.mapper.MapperListener  : Unregister host [localhost] at domain [null] for service [StandardService[Tomcat]]
2021-04-08 15:36:43.625 DEBUG 17920 --- [           main] o.apache.catalina.mapper.MapperListener  : Unregister Context [] for service [StandardService[Tomcat]]
2021-04-08 15:36:43.626 DEBUG 17920 --- [           main] o.apache.catalina.mapper.MapperListener  : Unregister Wrapper [dispatcherServlet] in Context [] for service [StandardService[Tomcat]]
2021-04-08 15:36:43.627 DEBUG 17920 --- [           main] o.a.c.c.C.[Tomcat].[localhost].[/]       : Stopping filters
2021-04-08 15:36:43.627 DEBUG 17920 --- [           main] o.a.c.c.C.[Tomcat].[localhost].[/]       :  Stopping filter 'requestContextFilter'
2021-04-08 15:36:43.628 DEBUG 17920 --- [           main] o.a.c.core.ApplicationFilterConfig       : JMX de-registration complete for filter of type [org.springframework.boot.web.servlet.filter.OrderedRequestContextFilter] and name [requestContextFilter]
2021-04-08 15:36:43.628 DEBUG 17920 --- [           main] o.a.c.c.C.[Tomcat].[localhost].[/]       :  Stopping filter 'Tomcat WebSocket (JSR356) Filter'
2021-04-08 15:36:43.628 DEBUG 17920 --- [           main] o.a.c.core.ApplicationFilterConfig       : JMX de-registration complete for filter of type [org.apache.tomcat.websocket.server.WsFilter] and name [Tomcat WebSocket (JSR356) Filter]
2021-04-08 15:36:43.629 DEBUG 17920 --- [           main] o.a.c.c.C.[Tomcat].[localhost].[/]       :  Stopping filter 'characterEncodingFilter'
2021-04-08 15:36:43.630 DEBUG 17920 --- [           main] o.a.c.core.ApplicationFilterConfig       : JMX de-registration complete for filter of type [org.springframework.boot.web.servlet.filter.OrderedCharacterEncodingFilter] and name [characterEncodingFilter]
2021-04-08 15:36:43.631 DEBUG 17920 --- [           main] o.a.c.c.C.[Tomcat].[localhost].[/]       :  Stopping filter 'formContentFilter'
2021-04-08 15:36:43.631 DEBUG 17920 --- [           main] o.a.c.core.ApplicationFilterConfig       : JMX de-registration complete for filter of type [org.springframework.boot.web.servlet.filter.OrderedFormContentFilter] and name [formContentFilter]
2021-04-08 15:36:43.631 DEBUG 17920 --- [           main] o.a.catalina.session.StandardManager     : Stopping
2021-04-08 15:36:43.633 DEBUG 17920 --- [           main] o.a.catalina.session.StandardManager     : Unloading persisted sessions
2021-04-08 15:36:43.633 DEBUG 17920 --- [           main] o.a.catalina.session.StandardManager     : No persisted sessions to unload
2021-04-08 15:36:43.634 DEBUG 17920 --- [           main] o.apache.catalina.core.StandardContext   : Sending application stop events
2021-04-08 15:36:43.634 DEBUG 17920 --- [           main] o.apache.catalina.core.StandardContext   : Processing standard container shutdown
2021-04-08 15:36:43.634 DEBUG 17920 --- [           main] org.apache.catalina.loader.WebappLoader  : Stopping this Loader
2021-04-08 15:36:43.635 DEBUG 17920 --- [           main] o.a.c.loader.WebappClassLoaderBase       : getResourceAsStream(org/apache/catalina/loader/JdbcLeakPrevention.class)
2021-04-08 15:36:43.635 DEBUG 17920 --- [           main] o.a.c.loader.WebappClassLoaderBase       :   Delegating to parent classloader sun.misc.Launcher$AppClassLoader@3f966a4f
2021-04-08 15:36:43.636 DEBUG 17920 --- [           main] o.a.c.loader.WebappClassLoaderBase       :   --> Returning stream from parent
2021-04-08 15:36:43.651 DEBUG 17920 --- [           main] o.apache.catalina.core.StandardContext   : resetContext Tomcat:j2eeType=WebModule,name=//localhost/,J2EEApplication=none,J2EEServer=none
2021-04-08 15:36:43.659 DEBUG 17920 --- [           main] o.apache.catalina.core.StandardContext   : Stopping complete
15:36:43.830 [main] ERROR org.springframework.boot.diagnostics.LoggingFailureAnalysisReporter - 

***************************

APPLICATION FAILED TO START

***************************

Description:

Field assetSuppository in gov.usdoj.afms.microsvc.service.AssetService required a bean of type 'gov.usdoj.afms.microsvc.repository.AssetRepository' that could not be found.

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

Action:

Consider defining a bean of type 'gov.usdoj.afms.microsvc.repository.AssetRepository' in your configuration.
k3fezbri

k3fezbri1#

我有点困惑,因为我很确定我以前做过,但它没有工作,但添加@enablejparepositories到应用程序类没有任何包规范,同时删除其他无关的注解为我工作。我还在存储库和控制器之间添加了一个assetservice,尽管我这样做时它不起作用,所以它不是真正的解决方案。。
但这似乎让我犯了下一个错误-

Field assetRepository in gov.usdoj.afms.microsvc.service.AssetService required a bean named 'entityManagerFactory' that could not be found.

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

Action:

Consider defining a bean named 'entityManagerFactory' in your configuration.

所以我还没开始工作,但这个问题已经解决了。

ujv3wf0j

ujv3wf0j2#

为了使spring-boot应用程序保持简单,应该遵循打包结构,这样spring-boot就可以扫描包并创建用于自动布线的bean。
在您的情况下,包结构应该如下
microapplication.java应该在mypkg.microsvc包中
assetcontroller.java应位于mypkg.microsvc.controller包中
assetrepository.java应位于mypkg.microsvc.repository包中
asset.java应该在mypkg.microsvc.entity包中
这种打包结构允许spring引导应用程序自动扫描所有包。这样,您就不必在主应用程序类中添加所有额外的锅炉板代码。spring-boot应用程序的目的是尽可能减少锅炉板代码

@SpringBootApplication
public class MicroApplication {
  public static void main(String[] args) throws Exception {
    SpringApplication.run(MicroApplication.class, args);
  }
}

相关问题