用的spring boot2
@Component public class ModeShapeSession { @Value("${modeshape}") String properties; public String run(){ return properties; } }
@RestController @EnableAutoConfiguration @RequestMapping("/oneScorpion/sdc/modeshape-Connections") public class ModeshapeController { @Autowired ModeShapeSession modeShapeSession; //返回nflow.serviceName,nflow.title @RequestMapping("/select-nflow-name") public String modeshape_select(){ return modeShapeSession.run()+"asasasa"; } }
程序启动的时候报错:
Field modeShapeSession in com.onescorpion.web.ModeshapeController required a bean of type 'com.onescorpion.connection.ModeShapeSession' that could not be found.
Action:
Consider defining a bean of type 'com.onescorpion.connection.ModeShapeSession' in your configuration.
@SpringBootApplication(scanBasePackages = "com.onescprpion.connection")
等着五花八门的都试过了,启动就是报错,初学者求指导
把项目结构,主要代码,配置文件都贴出来,其实按官方的来很简单
<pre><code>@Value("${modeshape:defaultValue}")</code></pre>
标题在误导人,是 modelShapeSession 找不到
<p>在启动类里面<a class="referer" target="_blank">@bean</a> 定义</p>
ModeShapeSession
版权声明:本文内容由阿里云实名注册用户自发贡献,版权归原作者所有,阿里云开发者社区不拥有其著作权,亦不承担相应法律责任。具体规则请查看《阿里云开发者社区用户服务协议》和《阿里云开发者社区知识产权保护指引》。如果您发现本社区中有涉嫌抄袭的内容,填写侵权投诉表单进行举报,一经查实,本社区将立刻删除涉嫌侵权内容。