据我所知,这个 问题 已经 被 问 几个 倍,但不幸的是,我一直没能得到我的日志配置工作.我必须在某个地方犯一些非常小的错误.
我有一个.NET 4.5 MVC 4/EF 5 Web应用程序,我正在尝试登录工作.该解决方案有两个项目,一个用于DAO和模型对象,另一个用于网站.App.Config文件如下所示:
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<configSections>
<!-- For more information on Entity Framework configuration, visit http://go.microsoft.com/fwlink/?LinkID=237468 -->
<section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=5.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
<section name="log4net" type="log4net.Config.Log4NetConfigurationSectionHandler, log4net" requirePermission="false" />
</configSections>
<connectionStrings>
<add name="RebuildingTogetherEntities" connectionString="stuff..."/>
</connectionStrings>
<entityFramework>
<defaultConnectionFactory type="System.Data.Entity.Infrastructure.SqlConnectionFactory, EntityFramework" />
</entityFramework>
<log4net configSource="Log.config" />
</configuration>
Run Code Online (Sandbox Code Playgroud)
同样的log4net部分也已复制到Web.Config文件中.
我在AssemblyInfo.cs文件中添加了以下内容:
[assembly: log4net.Config.XmlConfigurator(ConfigFile = "Log.config", Watch = true)]
Run Code Online (Sandbox Code Playgroud)
对于两个Log.Config文件,"复制到输出目录"设置为true.
我似乎可以将日志记录附加到输出文件的唯一方法是在第一个日志记录语句运行之前调用XmlConfigurator.Configure().当我第一次获得记录器时,我想我可以写一个外观来做到这一点,但这感觉不对.
如何在不手动调用XmlConfigurator的情况下初始化记录器?
假设您有一个C++类,如:
class Foo {
public:
virtual ~Foo() {}
virtual DoSomething() = 0;
};
Run Code Online (Sandbox Code Playgroud)
C++编译器将调用转换为vtable查找:
Foo* foo;
// Translated by C++ to:
// foo->vtable->DoSomething(foo);
foo->DoSomething();
Run Code Online (Sandbox Code Playgroud)
假设我正在编写JIT编译器,并且我想获取类Foo的特定实例的DoSomething()函数的地址,因此我可以生成直接跳转到它的代码,而不是执行表查找和间接分支.
我的问题是:
有没有任何标准的C++方法来做到这一点(我几乎可以肯定答案是否定的,但是为了完整起见,我想问一下).
有没有任何独立于远程编译器的方法,比如有人实现了提供访问vtable的API的库?
如果他们能够工作,我会完全打开黑客.例如,如果我创建了自己的派生类并且可以确定其DoSomething方法的地址,我可以假设vtable是Foo的第一个(隐藏)成员并搜索其vtable直到找到我的指针值.但是,我不知道获得这个地址的方法:如果我写的话,&DerivedFoo::DoSomething我得到一个指向成员的指针,这是完全不同的东西.
也许我可以将指向成员的指针转换为vtable偏移量.当我编译以下内容时:
class Foo {
public:
virtual ~Foo() {}
virtual void DoSomething() = 0;
};
void foo(Foo *f, void (Foo::*member)()) {
(f->*member)();
}
Run Code Online (Sandbox Code Playgroud)
在GCC/x86-64上,我得到了这个程序集输出:
Disassembly of section .text:
0000000000000000 <_Z3fooP3FooMS_FvvE>:
0: 40 f6 c6 01 test sil,0x1
4: 48 89 74 24 e8 mov QWORD PTR [rsp-0x18],rsi
9: 48 89 …Run Code Online (Sandbox Code Playgroud) 我正在使用Spring 3.1.2.RELEASE和cglib加载时编织,我正在尝试使用具有自定义注释和注释参数的方法.
建议:
@Aspect
public class MyAdvice
{
@Around("execution(@com.mycompany.locking.Lock * *(@com.mycompany.locking.LockVal(*), ..)) " +
"&& args(batch) && @args(propertyToLock)"
public Object lockAndProceed(ProceedingJoinPoint pjp, Object batch, LockVal propertyToLock) throws Throwable {
//Do stuff....
pjp.proceed();
}
}
Run Code Online (Sandbox Code Playgroud)
这是我正在测试的类:
public interface UpdateManager
{
public void processUpdate(MyBatchObject batch);
}
public class UpdateManagerImpl implements UpdateManager
{
@Lock
public void processUpdate(@LockVal("lockValue") MyBatchObject batch)
{
//Do stuff...
}
}
Run Code Online (Sandbox Code Playgroud)
问题是我无法获得执行建议.如果我删除了切入点中的@args和args条件,那么建议就会触发,但是我必须通过ProceedingJoinPoint来获取我需要的参数.
为什么不提出建议?我做错什么了吗?
编辑:以下切入点作为Spring的独立程序工作:
@Aspect
public class MyAdvice
{
@Around("execution(@com.mycompany.locking.Lock * *(@com.mycompany.locking.LockVal(*), ..)) " +
"&& args(batch)"
public Object …Run Code Online (Sandbox Code Playgroud) 我有一组WAR在JBoss 6.1.0.Final上没有问题,使用了使用Maven构建的AspectJ 1.6.12和Spring 3.1.2.RELEASE.我们希望在不久的将来转移到JBoss AS 7,所以我从源代码编译JBoss 7.1.3.Final.
在我遇到单个WAR文件的问题之后,我决定将应用程序重新打包为EAR文件,因此我们所有的代码都在一个可再发布的可部署单元中.
我无法让我们的分析方面发挥作用.这是一个非常简单的方面,包含在我们的EAR/lib目录中的JAR中,它使用@Timed注释注释的任何方法都是时间:
package com.mycompany.toplayer.perf;
import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.Around;
import org.aspectj.lang.annotation.Aspect;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Component;
@Component
@Aspect
public class MethodTimerAdvice {
private Logger log = LoggerFactory.getLogger(getClass());
@SuppressWarnings("unchecked")
@Around(value="execution(@com.mycompany.toplayer.perf.Timed * *(..))")
public Object timeMethod(ProceedingJoinPoint pjp) throws Throwable
{
String methodName = pjp.getSignature().toShortString();
long start = System.currentTimeMillis();
Object ret = pjp.proceed();
long end = System.currentTimeMillis();
long total = end - start;
long used_mem = Runtime.getRuntime().totalMemory()
- Runtime.getRuntime().freeMemory();
long mem_gb = used_mem / (1024 * …Run Code Online (Sandbox Code Playgroud) 我正在创建自己的自定义Filter类,以便在boost :: filtered_graph中使用.WeightMap概念必须具有默认构造函数,复制构造函数和赋值运算符.
我创建了下面的类,它有一个std :: shared_ptr私有成员.我的问题是我应该如何编写赋值运算符.复制构造函数不是问题,但赋值运算符不起作用.
class BFDMFilter
{
private:
const BGraph* m_battlemap;
const std::shared_ptr<MoveAbility> m_mv_ab;
public:
BFDMFilter() : m_battlemap(nullptr), m_mv_ab() { }
BFDMFilter(const BGraph* bmap, std::shared_ptr<MoveAbility> mv) : m_battlemap(bmap), m_mv_ab(mv) { }
BFDMFilter(const BFDMFilter& filter) : m_battlemap(filter.m_battlemap), m_mv_ab(filter.m_mv_ab) { }
BFDMFilter& operator=(const BFDMFilter& filter)
{
if(this != &filter)
{
m_battlemap = filter.m_battlemap;
m_mv_ab = filter.m_mv_ab;
}
return *this;
}
bool operator()(const Edge& edge) const
{
Tile::TileEdge path = (*m_battlemap)[edge];
return m_mv_ab->CanMove(path.TerrainType()) > 0.0;
}
bool operator()(const Vertex& vertex) const …Run Code Online (Sandbox Code Playgroud) 我正在尝试使用 Webpack 1.13.12 和 eslint 3.11.0 和 eslint-plugin-promise 3.4.0。我正在尝试使用这个问题的答案来让 Superagent 生成 Web 服务调用的结果。
import agent from 'superagent';
require('superagent-as-promised')(agent);
import Promise from 'promise';
const API_URL = 'http://localhost/services/merchant';
export function createVendorCall() {
const responsePromise = yield Promise.resolve(agent.put(`${API_URL}/create`));
let response = responsePromise.next();
return response.body;
}
Run Code Online (Sandbox Code Playgroud)
当我尝试对此进行检查时,eslint 抱怨说The keyword 'yield' is reserved. 我已尝试require-yield在 .eslintrc.json 文件中设置为 0,但它仍然不会 lint。使用内联注释禁用 eslint 也不起作用。
我应该怎么办?我是否以错误的方式使用 Superagent,或者是否有我必须禁用的规则?
编辑:这个问题被标记为这个问题的重复。然而,这个问题没有使用 linter,并且有不同的错误消息。这里的问题是 eslint 将看似有效的语法标记为错误。
我正在创建一个与Shopify的API集成的应用程序,该API使用OAuth2进行身份验证和授权。使用了Spring Security的OAuth2用户的教程,和教程的Shopify,我已经能够得到整合工作与单店。YAML配置如下所示:
shopify:
shop: myshop
scopes: read_customers,read_orders
security:
oauth2:
client:
clientId: myclientid
clientSecret: mysecret
tokenName: access_token
authenticationScheme: query
clientAuthenticationScheme: form
accessTokenUri: https://${shopify.shop}.myshopify.com/admin/oauth/access_token
userAuthorizationUri: https://${shopify.shop}.myshopify.com/admin/oauth/authorize?scope=${shopify.scopes}&grant_options[]=
pre-established-redirect-uri: https://myapp/login
registered-redirect-uri: https://myapp/login
use-current-uri: false
resource:
userInfoUri: https://${shopify.shop}.myshopify.com/admin/shop.json
Run Code Online (Sandbox Code Playgroud)
但是,此静态配置不适用于在Shopify的App Store中发布的应用程序,因为重定向,访问令牌,用户信息和用户授权URI取决于商店名称。 有使用多个提供程序的示例,但是它们仍然必须是静态的。
为了使这些URI动态,我提出了一些可能的选择:
在/login路径中使用参数来标识商店,然后创建一个过滤器,将商店名称添加到ThreadLocal在所有其他内容之前运行的,然后AuthorizationCodeResourceDetails通过Spring代理的工厂bean 动态创建OAuth2过滤器所需的。
使用一种“元过滤器”,它可以动态地重新创建OAuth2ClientAuthenticationProcessingFilter每个请求及其所需的所有资源。
重写,OAuth2ClientAuthenticationProcessingFilter以便它可以处理重新创建RestTemplate获取访问令牌所需的操作。
所有这些选项似乎都很困难。在Spring Security OAuth2中处理访问令牌和用户信息的动态生成的URI的好方法是什么?
另外,由于我通常是OAuth2的新手,是否需要在Spring配置中启用资源服务器以使用访问令牌保护我的应用程序?
我不知道如何找到这些单词..例子我有这个文字......
The other day I went to the <location> and bought some <plural-noun> . Afterwards, I went to <location> , but it was very <adjective> so I left quickly and went to <location> .
Run Code Online (Sandbox Code Playgroud)
当我搜索<和>谷歌时,我不知道搜索的原因,它将被忽略.需要帮助如何获得此字符串.
所以我会得到<location>,<plural-noun>,<location>,<adjective>,<location>
我必须使用这种charAt()方法.我的尝试:
String string = this.fileName;
for(int i = 0; i < string.length(); i++)
if((string.charAt(i) == '<') && (string.charAt(i) == '>'))
System.println(""); //<-------- IM STUCK HERE
Run Code Online (Sandbox Code Playgroud)
我不知道......差不多两天没睡觉了.
我目前但最后一个问题......如何移除<和 …
aspectj ×2
c++ ×2
.net ×1
aop ×1
c# ×1
c++11 ×1
charat ×1
ecmascript-6 ×1
es6-promise ×1
eslint ×1
java ×1
javascript ×1
jboss7.x ×1
log4net ×1
oauth ×1
shopify ×1
spring ×1
spring-aop ×1
superagent ×1