我想通过实现db数据init DataSourceInitializer.
我把这些作为方法就在我的Spring Boot主方法之下,但它似乎根本没有执行(我试图故意删除字符只是为了触发一个错误,这将确认执行.没有发生任何事情.):
@ConfigurationProperties(prefix="spring.datasource")
@Bean
public DataSource getDataSource() {
// i was hoping this was going to pull my current datasource, as
// defined in application.properties
return DataSourceBuilder
.create()
.build();
}
@Bean
public DataSourceInitializer dataSourceInitializer() {
ResourceDatabasePopulator resourceDatabasePopulator = new ResourceDatabasePopulator();
resourceDatabasePopulator.addScript(new ClassPathResource("/data/init/initData.sql"));
DataSourceInitializer dataSourceInitializer = new DataSourceInitializer();
// the call to the above method
dataSourceInitializer.setDataSource(getDataSource());
dataSourceInitializer.setDatabasePopulator(resourceDatabasePopulator);
return dataSourceInitializer;
}
Run Code Online (Sandbox Code Playgroud)
更新:此问题旨在获取对正在使用的dataSource的引用.这个问题解释了如何以一种非常简单的方式初始化数据: DataSourceInitializer不能在Spring boot 1.2上运行
我注意到Angular-UI已经停止了他们的UI-Select2指令,转而支持新的UI-Select(有多个主题 - select2,bootstrap,selectize).
它看起来像这样:
<ui-select multiple ng-model="multipleDemo.colors" theme="select2" ng-disabled="disabled" style="width: 300px;">
<ui-select-match placeholder="Select colors...">{{$item}}</ui-select-match>
<ui-select-choices repeat="color in availableColors | filter:$select.search">
{{color}}
</ui-select-choices>
</ui-select>
<p>Selected: {{multipleDemo.colors}}</p>
Run Code Online (Sandbox Code Playgroud)
最初我的选择框应该是空的但是准备好接受类型字符,即至少4个字符的字符串,然后进行API调用以检索要填充框的建议值列表.然后将选择一个值,并且应该根据需要重复搜索.
首先,我尝试$watch了ng-model在这种情况下multipleDemo.colors(在演示中使用此示例).API调用从未发生,然后我意识到了原因.实际模型根本不会更改,因为它只会在进行选择时更改(我的选择框为空,因此无法选择任何内容).
我的结论是,我应该(能够)$watch添加什么作为过滤器,即filter: $select.search.
有谁知道我应该如何在我的控制器中使用那个?
这个:
$scope.$watch('$select.search', function(newVal){
alert(newVal);
});
Run Code Online (Sandbox Code Playgroud)
不起作用.
编辑:对于任何人的参考,请参阅这个简短的讨论:是否可以添加对自定义查询功能的支持,如select2?
编辑2:
我通过$emit在指令中使用来解决这个问题,所以现在我的控制器中的值可用.但是现在我想知道如何覆盖指令的这一部分,以便指令本身可以保持原样,以便在将来的更新中不会中断?
angularjs angular-ui angularjs-directive angularjs-scope ui-select2
我很确定我在某处读过,您实际上可以将主插件 *.php 文件移动到其他地方(我假设在您的主题目录下),以确保它的安全,以防您对其进行更改并更新您的插件。我尝试谷歌但找不到任何东西。具有良好结果的 Google 页面就足够了。
我刚刚经历过一种情况,我的 2 个插件的布局发生了变化并满足了我的需求,我想确保这种情况不会再次发生。除了将主文件放在另一个位置之外,是否还有办法移动任何 CSS 和 JS 文件?
在 Concrete5 CMS 中,有一个很好的方法来做到这一点,通过在插件块(可以被视为 WP 插件)内创建一个新文件夹,您可以在其中创建主文件、任何 CSS 和 JS 文件的副本以及然后您可以简单地编辑它们并为您正在使用该块的页面位置选择该模板。
我假设 WordPress 中没有这样的东西,但是我能接近多少呢?
更新:我发现我在哪里应用了创建文件的新实例的建议,然后将其移动到主题目录。有问题的插件是 HL-Twitter。这些是插件文件:
admin.php
archive.php
functions.php
hl_twitter.php
hl_twitter_archive.php
hl_twitter_widget.php
import.php
widget.php
Run Code Online (Sandbox Code Playgroud)
现在,这是 hl_twitter_widget.php 的顶部内容(已注释掉):
Widget Theme for HL Twitter
To change this theme, copy hl_twitter_widget.php
to your current theme folder, do not edit this
file directly.
Available Properties:
$before_widget
$after_widget
$before_title
$after_title
$widget_title
$show_avatars
$show_powered_by
$num_tweets: how many tweets to show
$tweets: array of $tweet
$tweet: …Run Code Online (Sandbox Code Playgroud) 我对 Spring、JPA、Hibernate、Liquibase 还很陌生……但我正在尝试使用 Liquibase,这样我就可以让我的数据库与随着时间的推移应用于实体类的手动更改同步。另外,我希望 Liquibase 能够在现有数据保持原状的情况下应用 db 模式更新(这是否可能)?
在这个阶段,我有一个包含 3 列的实体类,它确实是在应用程序启动时创建的。此外,另一个表是通过 Liquibase 更改日志文件添加的(但没有实体类 - 这只是一个测试,看看 Liquibase 是否会生成表)。
这是我在我的pom.xml关于 Hibernate & Liquibase 的内容:
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
</dependency>
<dependency>
<groupId>org.liquibase</groupId>
<artifactId>liquibase-core</artifactId>
</dependency>
Run Code Online (Sandbox Code Playgroud)
现在,我知道Maven Liquibase和Liquibase-Hibernate5插件都存在。但是,由于我使用的是 Spring Boot 并且大多数东西都是自动配置的,所以我如何使用其中的任何一个?
更新: liquibase-hibernate5似乎是我需要的,因为它可以diff针对 JPA/Hibernate 映射启用当前数据库模式。但是,我还没有深入研究它并尝试让它发挥作用。与任何事情一样,这个插件并非没有问题,所以我开始怀疑是否值得麻烦,因为我们只讨论几个数据库保持同步。
我为此创建了一个plunker:http://plnkr.co/edit/5nk4BnYoO52En7P6kPu9
选择选项,但是当您选择一个时,ui-select保留为空白.潜在的重要说明:我在指令(ui-bootstrap)中使用它.作为旁注 - 在plunker中没有包装指令,所以这不是罪魁祸首.
<ui-select search-enabled="true" ng-change="updateMedu()" style="width: 100%" ng-model="medications.chosenMedications.metadata.conceptGroup.conceptProperties">
<ui-select-match placeholder="Please click to choose or start typing dosage value..">{{$item}}</ui-select-match>
<ui-select-choices repeat="cp in medications.chosenMedications.metadata[key].conceptGroup[1].conceptProperties | filter: $select.search">
{{cp.synonym}}
</ui-select-choices>
</ui-select>
Run Code Online (Sandbox Code Playgroud)
手动模拟数据集:
$scope.medications.chosenMedications.metadata = [
{
conceptGroup: [
{
conceptProperties: [
{synonym: "Item One"},
{synonym: "Item Two"},
{synonym: "Item Three"}
]
},
{
conceptProperties: [
{synonym: "Item A"},
{synonym: "Item B"},
{synonym: "Item C"}
]
}
]
}
];
Run Code Online (Sandbox Code Playgroud) 在阅读此实施OAuth 2.0身份验证(服务器端)时,我注意到该流程可能适用于创建应用程序的情况,该应用程序允许用户使用其Google凭据登录并随后显示其Google+帖子,Youtube视频等.
我需要的是能够根据谷歌用户的用户名或用户ID获取谷歌数据.我确实有来自Google的client_id,client_secret等 - 而且我愿意按照我的要求发送它们.
第1步似乎没问题.提出类似这样的请求:
https://accounts.google.com/o/oauth2/auth?
client_id=1084945748469-eg34imk572gdhu83gj5p0an9fut6urp5.apps.googleusercontent.com&
redirect_uri=http%3A%2F%2Flocalhost%2Foauth2callback&
scope=https://www.googleapis.com/auth/youtube&
response_type=code&
access_type=offline
Run Code Online (Sandbox Code Playgroud)
在这一步之后可能会有什么好处,只需要获取代码,以便我可以验证我的请求(通过Google_Client() - > authenticate($ _ GET ['code']);或类似的),然后将其交换为auth_token.
我使用Facebook API for PHP获得类似于获取Facebook个人资料/页面公共帖子的内容 - 因此与FB流程的登录不同 - 不需要用户同意也不需要用户同意.
我有一段这样的代码:
class EducationalCentre
{
string _centreName;
vector<Course> _courses; // courses offered by the Centre
Collection<Course*, Student*, 150> _applicants;
public:
EducationalCentre(string name="<name>")
{
_centreName = name;
}
EducationalCentre(const EducationalCentre& obj)
:_courses(obj._courses), _applicants(obj._applicants)
{
_centreName = obj._centreName;
}
};
Run Code Online (Sandbox Code Playgroud)
现在,在这部分_applicants(obj._applicants)复制构造标题中,周围有一条波浪形的红线(obj,将其悬停在错误上,说明类型不兼容(const正在提及).
因为我不想在这个阶段改变任何东西(这是考试测试的一部分) - 我想知道为什么会发生这种情况.
我试图删除const从EducationalCentre(const EducationalCentre& obj),这确实解决了问题,但..正如我所说,我宁愿了解是什么导致这而不是删除它.
angular-ui ×2
angularjs ×2
spring-boot ×2
c++ ×1
const ×1
datasource ×1
google-api ×1
google-oauth ×1
hibernate ×1
java ×1
javascript ×1
jpa ×1
liquibase ×1
maven ×1
oauth ×1
php ×1
spring ×1
ui-select2 ×1
wordpress ×1