我有一个非常简单的Spring Boot应用程序,我正在尝试使用一些外部化配置.我试图按照弹簧启动文档中的信息,但我正在遇到路障.
当我运行app.properties文件中的外部配置下面的应用程序时,不会填充bean中的变量.我确定我做的事情很愚蠢,谢谢你的任何建议.
MyBean.java(位于/ src/main/java/foo/bar /)
package foo.bar;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.stereotype.Component;
@Component
public class MyBean {
@Value("${some.prop}")
private String prop;
public MyBean() {
System.out.println("================== " + prop + "================== ");
}
}
Run Code Online (Sandbox Code Playgroud)
Application.java(位于/ src/main/java/foo /)
package foo;
import foo.bar.MyBean;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.boot.SpringApplication;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
@Configuration
@ComponentScan
@EnableAutoConfiguration
public class Application {
@Autowired
private MyBean myBean;
public static void main(String[] args) {
SpringApplication.run(Application.class, args);
} …Run Code Online (Sandbox Code Playgroud) Play 2.0使用SBT.但是,它提供了自己的SBT操作,idea以便为新项目创建模块.您必须自己创建一个IDEA项目并将模块添加到它.精细.
什么不好的是Play2在解压缩时从其源目录中使用,并且有一个repository/子目录实际上是一个常春藤存储库,与您的存储库分开~/.ivy2.
如何为应用程序配置SBT构建?在导入的库中,IDEA无法识别Scala编译器.
播放源不在repository/.当我publish-local从git构建Play 2.0时,它将jar存放在当前的2.0-RC3-SNAPSHOT那里,但不是源.运行SBT操作package-src确实产生了源jar,但它似乎留在原地.从IDEA附加它仍然没有显示来源FakeRequest.
是否最好依靠gen-ideaSBT代替idea?
我收到以下错误:
JPA错误发生JPA错误(无法构建EntityManagerFactory):模型上的@OneToOne或@ManyToOne.Issue.project引用未知实体:models.Project
在这里你可以看到我的实体:
package models;
import java.util.*;
import javax.persistence.*;
import play.db.jpa.*;
import models.Issue;
import models.Component;
public class Project extends Model{
public String self;
@Id
public String key;
@OneToMany (mappedBy="Project", cascade=CascadeType.ALL)
public List<Component> components;
@OneToMany (mappedBy="Project", cascade=CascadeType.ALL)
public List<Issue> issues;
public Project(String self, String key) {
this.self = self;
this.key = key;
this.components = new ArrayList<Component>();
this.issues = new ArrayList<Issue>();
}
public Project addComponent(String self, int component_id, String name, int issuecount) {
Component newComponent = new Component(self, component_id, name, issuecount, this); …Run Code Online (Sandbox Code Playgroud)