我最近切换了大部分Spring配置,在Spring 3.1中使用基于代码的配置.但是,现在我已经切换,我的Spring Security无法正常工作,并在Tomcat启动时抛出以下错误:
SEVERE: Exception starting filter springSecurityFilterChain
org.springframework.beans.factory.NoSuchBeanDefinitionException: No bean named 'springSecurityFilterChain' is defined
Run Code Online (Sandbox Code Playgroud)
我仍然在XML文件中有Spring Security,并且知道这不能在Spring中转换为Java配置,因为它是一个自定义命名空间,但是,我在我的Java配置文件中引用它.我也尝试将applicationContext-security.xml配置引用从Java配置移动到我的web.xml,没有任何运气.
@Configuration
@EnableWebMvc
@Import(ServicesConfig.class)
@ImportResource({ "classpath:applicationContext-security.xml",
"classpath:dataSources.xml" })
@ComponentScan(basePackages = "com.foobar")
public class WebConfig {
// left out Beans for clarity
}
Run Code Online (Sandbox Code Playgroud)
的applicationContext-security.xml文件:
<b:beans xmlns="http://www.springframework.org/schema/security"
xmlns:b="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:p="http://www.springframework.org/schema/p" xmlns:c="http://www.springframework.org/schema/c"
xmlns:oauth2="http://www.springframework.org/schema/security/oauth2"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-3.1.xsd
http://www.springframework.org/schema/security
http://www.springframework.org/schema/security/spring-security-3.1.xsd
http://www.springframework.org/schema/security/oauth2
http://www.springframework.org/schema/security/spring-security-oauth2.xsd">
<!-- Security configuration -->
<global-method-security pre-post-annotations="enabled" />
<http use-expressions="true" access-denied-page="/error/accessDenied"
entry-point-ref="casEntryPoint">
<intercept-url pattern="/**" access="isAuthenticated()" />
<custom-filter position="CAS_FILTER" ref="casFilter" />
</http>
<authentication-manager alias="authenticationManager">
<authentication-provider ref="casAuthenticationProvider" />
</authentication-manager>
<!-- Bean …Run Code Online (Sandbox Code Playgroud) 我使用的是带有 5.4 版 FreeRTOS 的 MSP430f5438。
我有一个有趣的问题,我无法弄清楚。
基本上,当我将 configTICK_RATE_HZ 设置为不同的值时,LED 闪烁得更快或更慢;它应该保持相同的速率。我将 configTICK_RATE_HZ 设置得越高,它闪烁得越慢,而当我将 TICK_RATE 设置得越低时,它就会闪烁得越快。
vTaskDelayUntil( &xLastFlashTime, xFlashRate ); 无论 configTICK_RATE_HZ 是多少,LED 应该每秒只闪烁一次。我逐步检查了 xFlashRate 以进行确定。它总是 = configTICK_RATE_HZ。代码:
xFlashRate = ledFLASH_RATE_BASE;//my flash base rate is 1000ms
xFlashRate /= portTICK_RATE_MS; //so xFlashrate = whatever configTICK_RATE_HZ equals
/* We need to initialise xLastFlashTime prior to the first call to vTaskDelayUntil().*/
xLastFlashTime = xTaskGetTickCount();
for(;;) {
vTaskDelayUntil( &xLastFlashTime, xFlashRate ); vParTestToggleLED( uxLED );
flashled();//this should happen every 1 second.
}
Run Code Online (Sandbox Code Playgroud)
当我将 configtick_rate_hz 设置为 1000 …
这是我的警报管理器代码:
Intent intent=new Intent(getBaseContext(),AlarmReciever.class);
intent.setAction("com.example.projectx.ACTION");
PendingIntent pendingIntent=PendingIntent.getBroadcast(this,12345, intent,PendingIntent.FLAG_CANCEL_CURRENT);
AlarmManager alarmManager=(AlarmManager)getSystemService(Activity.ALARM_SERVICE);
alarmManager.set(AlarmManager.RTC_WAKEUP,targetCal.getTimeInMillis(),pendingIntent);
Run Code Online (Sandbox Code Playgroud)
如果我选择在未来一小时/分钟启动的警报,代码工作得很好.但是如果我选择过去的小时/分钟,当我点击"设置闹钟"时会立即激活.
例:
现在是15:00,我将闹钟设置为15:45,闹钟在15:45关闭,一切正常
现在是15:00,我将闹钟设置为14:30,一旦点击"设置闹钟",闹钟就会响起!
我的时间选择器总是设置为24小时模式.这可能是个问题吗?
谢谢!
我们的 Java 程序从 postgreSQL 中随机获取数据。如何解决?为了按顺序获取数据应该做什么?
我们的 postgresql 中有一个名为grocery的表,其中的条目从0到99。java代码正在获取整个表,但以随机顺序。
connection = DriverManager.getConnection(
"jdbc:postgresql://localhost/test", "postgres",
"manafara");
connection.setAutoCommit(false);
Statement st = connection.createStatement();
String sql = "Select * from grocery";
ResultSet rs = st.executeQuery(sql);
Statement st1 = connection.createStatement();
ResultSet rs1 = st1.executeQuery("Select COUNT(*) AS TOTAL from grocery");
int n = 0;
while (rs1.next()) {
n = rs1.getInt("TOTAL");
}
System.out.println("Count: " + n);
int a = 0;
Double db[][] = new Double[n][2];
while (rs.next()) {
db[a][0] = (double) rs.getInt(4);
db[a][1] = rs.getDouble(6);
a++;
}
Run Code Online (Sandbox Code Playgroud)